- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2024 10:18 AM
can all involved approvers being listed in message body or only the approval recipient? or can show count of total approver?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2024 10:50 AM - edited 04-27-2024 11:06 AM
Hi @vinnus ,
Look I tried your problem in my PDI and it works for me I'm adding images for reference
I created before BR on sc_req_item and added below code
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var appArr = []
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.query();
while(gr.next()){
appArr.push(gr.approver.getDisplayValue());
}
gs.eventQueue('send.approval.notificatio', current, current.number, appArr);
})(current, previous);
Than I create event at I called in the script
Than in email notification I called the parm 1 and parm 2
Below is result
Note: If you want to call the email scirpt you can also use the below code
In notificaition you can call like this - ${mail_script:scriptName}
Add below code
Result of email script
Notification
Email Script
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// Add your code here
var appArr = []
gs.log('Hree in email script = ' + current.sys_id)
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.query();
while (gr.next()) {
appArr.push(gr.approver.getDisplayValue());
}
template.print(appArr);
})(current, template, email, email_action, event);
Output:
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
04-27-2024 10:02 PM
Hi @vinnus,
You can write an email script to get all approvers in the email body. You can refer to the below sample code.
// Add your code here var appArr = [] var gr = new GlideRecord('sysapproval_approver'); gr.addQuery('sysapproval', current.sys_id); gr.query(); while(gr.next()){ appArr.push(gr.approver.getDisplayValue()); }
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2024 10:29 AM
Hi @vinnus ,
This is possible to add all the approval in email body, you just need to create a event and in the parm1 or parm2 you can send the array of approvals and trigger the email notification when event is triggered. In email body you can send all the approvals like${event.parm1}.
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
04-27-2024 10:50 AM - edited 04-27-2024 11:06 AM
Hi @vinnus ,
Look I tried your problem in my PDI and it works for me I'm adding images for reference
I created before BR on sc_req_item and added below code
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var appArr = []
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.query();
while(gr.next()){
appArr.push(gr.approver.getDisplayValue());
}
gs.eventQueue('send.approval.notificatio', current, current.number, appArr);
})(current, previous);
Than I create event at I called in the script
Than in email notification I called the parm 1 and parm 2
Below is result
Note: If you want to call the email scirpt you can also use the below code
In notificaition you can call like this - ${mail_script:scriptName}
Add below code
Result of email script
Notification
Email Script
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// Add your code here
var appArr = []
gs.log('Hree in email script = ' + current.sys_id)
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.query();
while (gr.next()) {
appArr.push(gr.approver.getDisplayValue());
}
template.print(appArr);
})(current, template, email, email_action, event);
Output:
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
05-06-2024 09:55 PM
Hi Sarthak, Thanks for the help.
Need to populate the case record field value in Sys approval table notification email Subject.
Field name: Process
Case table: dfit_case
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 12:17 AM
Hi @vinnus ,
You can add this in Subject - Process : ${process(backend_value)}
Result
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak