Email Script Linking to Parent Record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2023 06:07 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2023 10:22 PM
current.getLink() will give you link of the record on which notification is created.
I assume it's on project table.
Are you saying you want link to breakdown record rather than project record?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2023 07:23 AM
Notification is created on Benefit Plan Breakdown table. As you are saying, I want link to Benefit Plan Breakdown.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2023 07:54 AM
if your notification is on Benefit Plan Breakdown table then the link will show take user to that record.
I didn't get your issue
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2023 07:59 AM
That is the issue @Ankur Bawiskar when I click on the button take_me_to_the_benefit in the email on gmail it takes me to the Project not to the Benefit Plan.