2 Replies Latest reply on Nov 1, 2015 10:27 AM by Mike_Mitchell

    How can I set a unique "priority" field in a set of portal records?

      Hi,

       

      I have a (common) case that contacts have several phone numbers (work. private, mobil, work fax, private fax etc,). I have a field in the numbers table that indicates if a number is the main-number (what I meant with "priority" in my titel here).

       

      The first number I add to a contact always gets this field set. Now I want to be able to change that if further numbers are added. I use an option-field, but can not get it work how I make all others de-selected (in an elegant way) when a new "main"-number is clicked.

       

      Ideas for the best way to do it?

       

      Thanks!

        • 1. Re: How can I set a unique "priority" field in a set of portal records?
          Menno

          There are lots of ways to achieve this and it is just a matter of taste. You either set a value on the portal-records, but then as you noticed there emerges the need to change something on all the other records.

           

          Since there is a relation between the "mother" and the "children" you can utilize that relation by sorting the records in the portal on a value in the "children" and that value should be an un-stored calculation, which checks for a value in the "mother".

           

          Create a field in the "mother"-table called "main_id" (or anything else you think is appropriate) and just put the primary-key of the record with the "main-number" there. Create a calc in the "child"-table and check over the relation if the valus set in the "mother" is equal to its primary-key and if so, set 1. Because it is using a relation, it'll be un-stored, but you won't start searches over that field, so it doesn't matter.

           

          Now you can use protal-sorting to show the "main"-record on top of all others in the portal.

          • 2. Re: How can I set a unique "priority" field in a set of portal records?
            Mike_Mitchell

            I would use a script for this. Navigate to the related records, recording the record ID of the record the user clicked. Set that one to "primary". Set all others to "not primary".