- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2020 04:19 AM
Hi All,
I need to trigger email notification based on the event triggered, If we have errors in transform history then i have to trigger 'xyz' event , if if there are no errors then 'abc' event..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2020 09:36 AM
Hi,
So you created after update BR as per above screenshots;
please update code as below; I forgot to query Import Set table with the current Import Set and then passed the GlideRecord Object to that eventQueue()
Updated Now: Ensure you set valid recipient for the event;
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var importSet = new GlideRecord('sys_import_set');
importSet.addQuery('sys_id', current.set);
importSet.query();
if(importSet.next()){
if(current.state == 'complete' && current.total > 0){
gs.eventQueue("sn_customerservice.branch.alldata", importSet, recipient, importSet.number);
}
else if(current.state == 'complete_with_errors' || current.total == 0){
gs.eventQueue("sn_customerservice.branch.info.failure", importSet, recipient, importSet.number);
}
}
})(current, previous);
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
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
06-08-2020 07:19 AM
Hi,
if you have put this in onComplete then it should not show state as Running
Ensure you create onComplete Transform Script only
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
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
06-08-2020 07:31 AM
Yes its in oncomplete script only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2020 07:42 AM
Hi,
Possibly the last record taking more time to run;
Did you verify the last record got processed when this script ran?
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
06-08-2020 08:22 AM
Hi,
to be on safer side you can try after update BR on Transform History Table
BR: After Update
Condition: State is one of Complete/Complete with errors && current.set.data_source == 'yourDataSourceSysId'
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if(current.state == 'complete' && current.total > 0){
gs.eventQueue("sn_customerservice.branch.alldata", import_set, import_set.sys_id, import_set.number);
}
else if(current.state == 'complete_with_errors' || current.total == 0){
gs.eventQueue("sn_customerservice.branch.info.failure", import_set, import_set.sys_id, import_set.number);
}
})(current, previous);
Screenshots:
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
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
06-08-2020 08:47 AM
I Placed a log before the event, getting the below error
org.mozilla.javascript.EcmaError: "import_set" is not defined.
Caused by error in sys_script.28fbe119dbd158dcb976671cd3961941.script at line 1
==> 1: (function executeRule(current, previous /*null when async*/) {
2:
3: gs.info("I am in BR1");
4: if(current.state == 'complete' && current.total > 0){