Using Related Function with Multiple Related Fields in One Record

Trying to figure out the best way to deal with multiple related fields in one record. I'm building Sugar for a law firm. In each Case record, they want to be able to see the Lawyer on the other side - which is a related field to Contacts, the Judge - which is also a related field, the Defendant - yet another related field to Contacts.

Yes, these Contacts are listed in the subpanel of the Case module, but they want to be able to see these primary contact's information on a tab in the Case record to avoid hunting through all the related Contacts in each Case - which can be extensive.

I'm trying to figure out a way to distinguish the difference between each related field to be able to pull the Judge's assistant's name and phone number into the Case record, as well as the Lawyer and their assistant's contact details when using the related($contacts,.....) formula.

The problem is, Sugar doesn't know which Contact to pull this data from when there are multiple contacts related to a record. I asked Sugar support for some insight and this feature is already documented in Enhancement Request 66796.

Sugar Support offered the following idea for a possible workaround: "If you have multiple related records and wish to pull a specific phone number field from one of the records, you would have to flag that record somehow. For example, if you placed a checkbox on the related contact that you want to use and named it 'Use this record' or something to flag it as the record to reference. Then in your formula you could use ifElse() to determine which related record to use. If user_this_record_c equals 1, then pull the related phone number field. I believe that might work for you but you would have to test it."

I haven't tried this yet, but am planning to. In the meantime, has anyone encountered this issue and thought of a better way to go about a solution?

Thank you for any insight! I greatly appreciate it.

  • I don't see a way for this to work in SugarLogic.  I think you are going to have to write (or have written) a bit of custom code that retrieves the info during the API call.  The logic shouldn't be too bad and its the only way I can think of to still use the stock relationship and still get specific info out of it.

  • Ideally, you would have a qualifier on the relationship. Similar to the Contact Rank on the Contacts subpanel in Opportunities (aka opportunity_role). Then you should be able to use that qualifier on the relationship to pull the correct contact's information by filtering relationship results.

    I haven't looked into how to create such a field in 7.x yet, but since it exists in Opportunities there must be a way

    HTH

    FrancescaS

  • Thank you for your help! Yes, I was thinking we need to rely on the role to try and bypass this issue. I will report back once we are finished trying out the solution. Thanks again!

  • We achieved the function we needed with a custom code solution. Thanks for your help!