Forum Discussion

AngelRodriguez's avatar
AngelRodriguez
Qrew Assistant Captain
4 years ago

Limit child record status with a checkbox

I currently have two tables in my app, 'Vendors' (parent) and 'Vendor Contacts' (child) - one Vendor to many Vendor Contacts.

In my Vendor Contacts table, I added a checkbox named 'Primary Contact'. I'm trying to limit Vendors to allow only one Vendor Contact with the 'Primary Contact' status. I created a reverse relationship as well, where Vendor Contacts is the parent to Vendors, with Primary Contact as a lookup field in the Vendors table.

At this point, I'm not certain what to do to next to make sure that Vendors only has one Primary Contact checked off where I can hide the checkbox if Primary Contact is already selected in any of the Vendor Contacts related to one Vendor.


------------------------------
AR
------------------------------

4 Replies

  • You could use a data validation rule (advanced table settings) in your vendor contacts table. 

    1. Summarize # of primary contacts up to Vendors (you probably already have this)
    2. Create a lookup of # of primary contacts down to Vendor Contacts
    3. Create a data validation rule in Vendor Contacts, something like If  [# of primary contacts]>0​​ (or not null depending on your field settings), "You already have a primary contact...."*

    If you do have the reverse relationship you could also lookup that persons info back to vendor contacts as well and incorporate that into your data validation message, i.e. "...his name is xxxxxx"

    hope that helps!

    ------------------------------
    Charlie Murawski
    ------------------------------
    • AngelRodriguez's avatar
      AngelRodriguez
      Qrew Assistant Captain
      Hi Charlie,

      I tried summarizing the number of primary contacts up to Vendors, but I got an error message: "That summary function cannot be applied to this field".

      Thanks,
      Angel

      ------------------------------
      AR
      ------------------------------
      • CharlieMurawski's avatar
        CharlieMurawski
        Qrew Cadet
        You'd want to configure your summary as: "number of Contacts related to that vendor" and filter where primary contact = checked

        ------------------------------
        Charlie Murawski
        ------------------------------