How do I add a CC to an email from a dot walked field on the Parent record

allentschumper1
Tera Contributor

Hello, 

So I am trying to get an email address added as a CC to an email notification.  I already have the email/mail script built...but now I am not sure how to get it to work.

 

Here's the code...

 

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {

    // Add your code here
    //email.addAddress("cc", current.assigned_to.email, current.assigned_to.name);
    email.setSubject(current.request_item.variables.frt_inb_carrier_file_type + ' EDI Certification Testing - ' + current.request_item.variables.carrier_account.name + ' and ' + current.request_item.variables.shipper_account.name);
    email.setFrom('Freight.customer.support@usbank.com');
    template.print('Hello ' + current.request_item.variables.frt_technical_team_contact_name + ',\n\n' + 'I had initially reached out two weeks ago regarding the EDI Certification testing for the ' + current.request_item.variables.frt_inb_carrier_file_type + ' transaction set between ' + current.request_item.variables.carrier_account.name + ' and ' + current.request_item.variables.shipper_account.name + '. \n\nI am following up now to see whether you have questions, or if you are able to confirm when you will send a test file. \n\nThank you,\n' + current.assigned_to.name + '\n' + current.assigned_to.email + '\n\n' + current.request_item.number);

    if (current.sys_class_name == 'sc_req_item') {
        // if (current.assigned_to.email)
        {
            var useremail = current.variables.frt_technical_team_contact_email_address.getDisplayValue();
            var username = current.variables.frt_technical_team_contact_name.getDisplayValue();
            email.addAddress("cc", useremail.toString(), username.toString());
        }
    }


})(current, template, email, email_action, event);

 

The most important part is that in the BOLD.  What I am trying to do is get the value from a variable on the parent record.  The current record is a TASK (sc_task) and the parent is an RITM (sc_req_item).  The variable name is frt_technical_team_contact_email_address and the field is a type = Email.  

 

allentschumper1_0-1722143696914.png

This is a screen shot of the variable.  As you can also see in the BOLD code, it's trying to get the name of the person associated to the email address.  that variable is a single line text type.  

 

Suggestions?

0 REPLIES 0