Survey Notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi Experts,
I have a requirement where I have created the notification on the core case table and same notification is sent for all COEs. Now I want to insert a line in notification body to tell if this is a payroll case or benefits case or any other COE . I want to achieve this through an email script . Can any one of you suggest how we can do this .
Thanks in advance !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
- Navigate to System Notification > Email > Notification Email Scripts.
- Click New.
- Fill out the form:
- Name: case_coe_identifier (or similar descriptive name)
- Script:
// Get the display name of the COE from the current case record // The exact field name might vary (e.g., 'coe_code', 'topic_category.name', 'hr_service.name') // We will try using 'topic_category.name' which is common. var coeName = current.getValue('coe_code'); // Try this common field first if (!coeName) { // If coe_code is empty, try getting it from the HR Service or Topic Category reference if (current.hr_service.topic_category.name) { coeName = current.hr_service.topic_category.name; } else if (current.hr_service.name) { coeName = current.hr_service.name; // Fallback to HR service name } } if (coeName) { template.print("This case is related to the **" + coeName + "** Center of Excellence."); } else { template.print("This case is related to a specific COE."); // Fallback if no specific COE is found }
And In your notification include this email script
${mail_script:case_coe_identifier}If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
Thanks, GP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @Juhi Chawla2 ,
I tried your problem in my PDI and it works for me please Check steps below
I created email script and add below code
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// Add your code here
gs.info("current table = " + current.getValue('sys_class_name'));
var tableName = current.getValue('sys_class_name');
if(tableName == "sn_hr_core_case_payroll" || tableName == "sn_hr_core_case_total_rewards"){ // you can add your own tables here
template.print("This is payroll and benefit table");
}else{
template.print("This is other table");
}
})(current, template, email, email_action, event);
Add that email script in notification body
Result
For normal table
For payroll/ benefit table
Please mark my answer correct and helpful if this works for you
Thanks and Regards,
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday - last edited yesterday
Can you help me how we can write the template.print if I want the COE name mentioned in the below screenshot .if it is payroll we should be getting payroll in place of HR in the below screenshot.
Thanks a lot for your help in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @Juhi Chawla2 ,
I tried to add COE name and HR Service please check below image
Script
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// Add your code here
gs.info("current table = " + current.getValue('sys_class_name'));
var tableName = current.getValue('sys_class_name');
if(tableName == "sn_hr_core_case_payroll" || tableName == "sn_hr_core_case_total_rewards"){
template.print("This is payroll and benefit table" + " Coe name = " + current.hr_service.topic_detail.topic_category.coe + " HR Service = " + current.hr_service.getDisplayValue());
}else{
template.print("This is other table" + current.hr_service.topic_detail.topic_category.coe);
}
})(current, template, email, email_action, event);
Please mark my answer correct and helpful if this works for you
Thanks and Regards,
Sarthak
