- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 10:48 AM
good day,
i am trying to figure out how to script in a "TO: email address for the email notifications when a SC_REQ_ITEM gets updated.
Base on the Location the TO email address will be different
i have this but doesnt seem to work
if (revised == 'Yes') {
if (rushPay == 'Yes') {
email.subject = 'RUSH PAYMENT ' + approvedStatus + ': ' + expenseType + ' - ' + number + '[Revised]';
if (stage == 'fulfillment') {
if (location == 'Toronto') {
email.addAddress('to', 'Ip@something.com', 'Invoice Processing');
}
}
} else {
email.subject = approvedStatus + ': ' + expenseType + ' - ' + number + '[Revised]';
if (stage == 'fulfillment') {
if (location == 'Toronto') {
email.addAddress('to', 'Ip@something.com', 'Invoice Processing');
}
}
}
} else if (revised == 'No') {
if (rushPay == 'Yes') {
email.subject = 'RUSH PAYMENT ' + approvedStatus + ': ' + expenseType + ' - ' + number;
} else {
email.subject = approvedStatus + ': ' + expenseType + ' - ' + number;
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 11:11 AM
-> Create a new BR, say After- Update
-> In the condition select "Item IS ItemName"
-> In the script section -> mention your all the script which you mentioned above
-> Create a new event in event registry
-> Update your email notification to trigger it using event and check the checkBox as "parm1 contains recipients"
->trigger the event in BR using gs.eventQueue('Name_of_event',current,'RECIPIENTS DETAILS');
forexample:
if(condition. == "1"){
gs.eventQueue('Name_of_event',current,'RECIPIENTS DETAILS1');
}else{
gs.eventQueue('Name_of_event',current,'RECIPIENTS DETAILS2');
}
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 11:04 AM
Can't you create a Business Rule on the 'sc_req_item' table, specify your catalog item in the condition, and trigger an event in the script section of the Business Rule? You can pass the recipients as event parameters and capture them in ServiceNow.
Alternatively, if your catalog item has a workflow, you can trigger the event from there and pass the recipients from the workflow.
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 11:06 AM
how would you suggest the BR way of doing it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 11:11 AM
-> Create a new BR, say After- Update
-> In the condition select "Item IS ItemName"
-> In the script section -> mention your all the script which you mentioned above
-> Create a new event in event registry
-> Update your email notification to trigger it using event and check the checkBox as "parm1 contains recipients"
->trigger the event in BR using gs.eventQueue('Name_of_event',current,'RECIPIENTS DETAILS');
forexample:
if(condition. == "1"){
gs.eventQueue('Name_of_event',current,'RECIPIENTS DETAILS1');
}else{
gs.eventQueue('Name_of_event',current,'RECIPIENTS DETAILS2');
}
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 11:22 AM
worked like a charm thank you