concatenate multiple contact emails into a single account field

Hello!

We added a custom checkbox field ("Billing Contact") to our CONTACTS module. If there are 10 CONTACTS belonging to a single ACCOUNT, any of the CONTACTS could have the "Billing Contact" checked.  That means when we send a billing notice to that ACCOUNT each of the billing contacts should get a copy of the invoice.

Sugar is integrated with our billing system (QB), which sends out the billing invoices. 

We'd like to create a non-display field on the ACCOUNT called "Billing emails" and then concatenate all of the CONTACTS email addresses together for CONTACTS who are checked as "Billing Contacts."  So our non-display field would contain:  "email1@email.com;email2@email.com...".  We would then map this non-display field to our QB interface and QB would send the invoice to everyone.

I recently learned how to use the rollup functions (thanks to people in this forum) which loops through all related records to do math things.  I was hoping there was similar functionality that would let me loop through all of the CONTACTS that are "Billing Contacts" and concatenate their email addresses together to suit our purposes.  But nothing jumps out to me in any of the forums, documentation, or Google searches.

If anyone can suggest an approach to this that I'm not seeing, I would really appreciate it.

Thank you!

Bob

  • Hi

    You have got a clever idea!

    Unfortunately such a sugarLogic function doesn't exist but it can be implemented accordingly.

    We have created several sugarLogic function either for generic or very specific customer purpose.

    Let me know if you would like to have it implemented asap.

    Kind regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Hi BobUnfortunately, you can't use formulas to solve this task because calculated fields will be updated only after account saving. If you change and save a related contact, this change will not be reflected on an account level until this account won't be saved. 

    You can automate such routine with programming, as Andre has suggested, or with Logic Builder

    Logic Builder doesn't require knowledge of programming or SQL and was designed for CRM consultants, business analysts, and admins to automate Sugar by a trigger, by schedule, or inside a SugarBPM workflow:
    - automate calculations of any complexity
    - set up intelligent data sharing & update
    - provide smart data validation & input control
    - compose CRM data into informative and easy-to-read text for emails, messages, or notes
    - ensure flexible data exchange by REST API and not only
    - embed the ready-to-use power of Amazon Web Services into your CRM

    Like programming, you will have a safe-upgrade Sugar extension compatible with on-site and cloud Sugar, and you can change and manage this extension as you wish.

    Let me know if you need more info on how to configure data processing for integration purposes. 

    Regards,
    Mykola

    Integroscrm.com
    We make work in Sugar
    more convenient and efficient

  • Hi Bob,

    Okay, it looks like writing this post will take more time than configuring a solution :)
    It's so easy for Sugar admins to make it with Logic Builder configurator (https://logicbuilder.integroscrm.com) so I just did it

    I configured a logic hook on contact save that does what you need - each time Contact record is saved, it refreshes Billing Emails field for ACCOUNT by reconsidering the list of CONTACTS that belongs to the ACCOUNT and reconcatenates the value from CONTACTS emails on the basis of the state of checkbox Billing Contact 

    To make it work on your Sugar please
    1) check whether the custom fields in your Sugar has names highlighted with yellow on the screenshots below
    2) Install the zip package provided below via Module Loader
    3) enjoy the solution configured

    Screenshots:
      

    Zip:
    z20210201_flowchart_lb393.zip

    If you like to know how I did it so fast, just sign up to https://logicbuilder.integroscrm.com and I will share a flowchart with you so that you could change or adjust the logic for this task yourself.

    Here is how the configuring of the logic hook looks like (to read the drawing just enlarge the picture below then follow the white line).

    I'm looking forward to the feedback here whether it works for you!

    Best Regards,
    Dmytro Chupylka

    integroscrm.com
    We make work in Sugar CRM system faster, more convenient and efficient

  • Thank you for your input, André! It was probably too much to hope for that it would be an out-of-the-box thing.

  • This is an old question, but I came across it while answering a similar enquiry so I thought I would update here for anyone else coming across it.

    I would go a totally different route and not try to concatenate emails into a field... you'll get yourself in trouble and potentially not have current information when a Contact gets updated and the Account does not.

    But I'm a developer, and you'll need one on hand for this:

    I don't know what your integration looks like but I assume QB is leveraging your Account ID to get the information needed for the the billing invoices (else how would you even get the non-display field you mentioned)

    It should be easy enough (with a programmer's help) to extend that integration to get related Contact records with the "billing_contact_c" flag set by leveraging the Sugar's APIs and filter construct.

    see a basic example for contacts related to an account here:

    https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_12.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Related_Records/index.html

    The API call, with the added filter, would look something like:

    '/Accounts/60f2b566-30b5-11ea-8ef6-001a4a160206/link/contacts?filter[0][billing_contact_c][$equals]=1';

    where 60f2b566-30b5-11ea-8ef6-001a4a160206 is the Account ID for the Account in question.

    The results would look something like what you see in the link above (a bit ugly, I know) but the only Contacts related to the Account that are returned would be the ones marked "Billing Contact" at the time that the API is called, and extracting the primary email address for each one from there would not be hard.

    This way you always get current and up-to-date information and don't have to worry about formulas triggering or not triggering etc.

    Even better, would be a custom API that given an Account ID returns the concatenated email addresses of the related contacts that have the flag set.
    That would be a pretty simple piece of code, for a PHP developer with some Sugar knowledge, that leverages the Sugar Beans.

    Again, you would get the most current information and don't have to worry about formulas triggering or not triggering etc..

    In either case you will need someone to work on your QB integration code and possibly Sugar code to get the best results.

    Hope this helps give you some ideas,

    FrancescaS