- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2022 09:51 AM
Hi,
I want to display variables content into a notification
Accessing variables doesn't work directly in notification HTML so i've created an email script
I can display some variables (e.g. a date variable) but I can't get others like reference to sys_user table
I tried several methods but it always displays 'undefined'
All my variables are part of variable sets and I'm sure of the variable names
In the script below, only the current.variables.v_change_date.getDisplayValue() displays something right
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
template.print(current.variables.v_employee_name.first_name);
template.print(current.variables.v_employee_name.first_name.getDisplayValue());
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',current.variables.v_employee_name);
gr.query();
if (gr.next()){
template.print(gr.first_name);
template.print(gr.first_name.getDisplayValue());
}
template.print("Le changement de responsable de " + current.variables.v_employee_name.name.getDisplayValue() + " de " + current.variables.v_former_manager.name + " vers " + current.variables.v_new_manager.name + " a été fait dans SX en date du " + current.variables.v_change_date.getDisplayValue() + ".");
})(current, template, email, email_action, event);
Solved! Go to Solution.
- Labels:
-
Request Management
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 08:22 AM
So here is the issue
your notification is on sc_req_item table but the object you are passing to eventQueue() is current which is sc_task table
Do this
gs.eventQueue('event_name', current.request_item.getRefRecord(), f_manager, n_manager);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 04:03 AM
Hi,
should not be the case.
Did you check issue is only for this catalog item or in complete instance for other catalog items?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 05:38 AM
more in depth, a business rule generates the event that triggers the notification
This business rule is based on sc_task table and provide recipients to the notification
so it might 'force' the notification to be at task level despite it's declared on table sc_req_item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 05:53 AM
Hi,
if notification is on sc_req_item then this logic should work
current.variables.variableName
can you share your BR script and notification configuration screenshot
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 08:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 08:22 AM
So here is the issue
your notification is on sc_req_item table but the object you are passing to eventQueue() is current which is sc_task table
Do this
gs.eventQueue('event_name', current.request_item.getRefRecord(), f_manager, n_manager);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader