Creating a calculated field using Email of a related Record

In studio, when creating a calculated field for a related record, I'm not able to select Email.

Here's the formula I'm using:

related($atc_clientsalesreps_atc_appointments,"email")

After saving that formula and Mass Updating both the parent record and related record, the calculated field returns 'Array' instead of the expected email address of the related record.

Any help would be much appreciated!

Thanks,

Alex

  • I think email retrieved is something like:

       "email":[      
    {"email_address":"me@my.crm"
    ,"primary_address":"1"
    ,"invalid_email":"0"
    ,"opt_out":"0" }]

    You could try using email1, though I seem to recall reading somewhere that it is going away.

    Is your heart set on using Sugar Logic? You could use a before save to retrieve the email address and populate the field or, depending on your scenario, use the controller to fetch and populate the email address in your field before the user saves the record.

    HTH

    Francesca

  • Hello Alex Wilder

    I was able to get the email from a related record following these steps:

    Module A: Source record.

    Module B: Target record.

    Create a calculated text field in module A, let's name it module_a_email_c and set this formula in:

    related($email_addresses,"email_address")

    Create a calculated text field in module B, let's name it email_from_a_c and set this formula in:

    related($module_a,"module_a_email_c")

    Keep in mind that there should be an actual relationship between these two modules. 

    I hope this helps.

    Regards, 

    Angel M.

  • Hello Alex,

    You are getting the "Array" response because emails are usually stored in an Array. You are calling the Array, not the elements. What you need to do is select the email element from the Array and display it in your field. Please see the image below.

    Your formula is: related($atc_clientsalesreps_atc_appointments,"email")

    The new formula is: related($atc_clientsalesreps_atc_appointments,"email1")

    Please notice that I write "email1" instead of "email". This way you are able to select the first element of the Array.

    In order to implement this approach, you need to have a relationship between these two modules.

    Sergio N.

  • I would caution against using email1 since it has been deprecated and will be removed:

    "We observe many examples of custom code (and some core code) that still use the old email# fields. This is probably because it is convenient to use the email1 field like a regular text field.But this is out of date, inaccurate, deprecated, and subject to removal in upcoming Sugar releases."

    https://community.sugarcrm.com/community/developer/blog/2017/08/01/using-e-mail-fields-correctly-in-sugar