- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2024 10:17 PM
try this and replace your correct variable name
${current.variables.requested_for}
If the above doesn't work then
you can store those variables in workflow scratchpad and then use in notification like this
1) run script
workflow.scratchpad.requestedFor = current.variables.requested_for;
workflow.scratchpad.deviceStolenDate = current.variables.<dateVariable>;
2) in notification message use like this
A lost or stolen device has been reported by ${workflow.scratchpad.requestedFor}
The device was lost or stolen on ${workflow.scratchpad.deviceStolenDate}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2024 10:42 PM
still error is coming
This is my mail script
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var requester = current.requested_for.getDisplayValue();
var date = current.variables.date_item_was_lost_stolen.getDisplayValue();
email.setSubject(current.short_description_1);
template.print("<p>A lost or stolen device has been reported by " + requester);
template.print("<p>The device was lost or stolen on " + date);
template.print("<br />");
template.print("Description:" + current.description_1);
})(current, template, email, email_action, event);
This is the catalog
Short description and description we are getting from variable set
You can see in the notification preview short descp and descirption are shwoing undefined ,
can you please tell me what was the mistake here and what correction required .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2024 11:01 PM
you are using the wrong syntax to get variable value
the correct syntax is current.variables.variableName
update as this
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var requester = current.variables.requested_for.getDisplayValue();
var date = current.variables.date_item_was_lost_stolen.getDisplayValue();
email.setSubject(current.variables.short_description_1);
template.print("<p>A lost or stolen device has been reported by " + requester);
template.print("<p>The device was lost or stolen on " + date);
template.print("<br />");
template.print("Description:" + current.variables.description_1);
})(current, template, email, email_action, event);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2024 11:03 PM
You are missing the variables before the varible, have a look at updated code
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var requester = current.requested_for.getDisplayValue();
var date = current.variables.date_item_was_lost_stolen.getDisplayValue();
email.setSubject(current.variables.short_description_1);
template.print("<p>A lost or stolen device has been reported by " + requester);
template.print("<p>The device was lost or stolen on " + date);
template.print("<br />");
template.print("Description:" + current.variables.description_1);
})(current, template, email, email_action, event);
Mark this as Helpful / Accept the Solution if this clears your issue
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2024 12:59 AM
I have checked in email logs , there is no email sent
can you please tell what was issue here .