Email Script Linking to Parent Record

Daniel142
Tera Expert

Hi guys!

This is the issue I'm getting, I hope someone can help me.

When I open an email notification in GMail on a browser where I'm impersonated as Project Manager, when I click on the email script take_me_to_the_benefit_plan it links me to the parent record, the Project.

 

This notification is fired by an event with this parameters:

 

 if (project.getValue('u_related_it') == 'no' && project.getValue('u_financial_benefitsmonitoring') == true) {

        benefit_plan_breakdown.u_approval = 'requested';
        benefit_plan_breakdown.u_due_date_approval = true;
benefit_plan_breakdown.update();
        gs.eventQueue("send.projectManager.email", project, project.getUniqueValue(), project.project_manager);
        
    }
}​

 

 

This notification must be sent to the Project Manager (this happens), but with record information of the benefit plan breakdown(Also this happens).

 

Here is the link code that I'm trying to use:

 

(function runMailScript(current, template, email, email_action, event) {
	
    var link = current.getLink();

    var backgroundColor = 'background-color: #cc1233;';
    var border = 'border: 1px solid #4d0713;';
    var color = 'color: #ffffff;';
    var fontSize = 'font-size: 18px;';
    var fontFamily = 'font-family: Helvetica, Arial, sans-serif;';
    var textDecoration = 'text-decoration: none; border-radius: 3px;';
    var webKitBorder = '-webkit-border-radius: 3px;';
    var mozBorder = '-moz-border-radius: 3px;';
    var display = 'display: inline-block;';
    var padding = 'padding: 5px;';


    template.print('<a href="' + link + '"');
    template.print('style="' + backgroundColor + border + color + fontSize + fontFamily + textDecoration + webKitBorder + mozBorder + display + padding);
    template.print('">');
    template.print(gs.getMessage('Take me to the Benefit Plan Breakdown'));
    template.print('</a>');
    template.print('</font>');
    template.print('<br><br>');
    template.print('<p><font size="3" color="#808080" face="helvetica">');
    template.print(gs.getMessage('Thank you.'));
    template.print('</font></p>');

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

 

 

 

The defect/issue I'm trying to solve is that I'm not getting the Benefit Plan Breakdown record that must be updated. I'm gettin the parent record.

 

Hope someone can help me, please.

8 REPLIES 8

@Daniel142 

Did you print what came in the link?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar This is the result of the variable link:

Daniel142_0-1690989771898.png

 

@Daniel142 

Strange

Did you try printing current.sys_id and it's giving project sysId or Breakdown sysId?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar Line 7, I print current.sys_id which is giving me the id of the project.

Daniel142_0-1690990808115.png