setAbortAction is not working in Scoped application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2021 11:27 PM
Hi,
I am currently on a Human Resource Core scope and on the Record producer General inquiry i have an option as Type of issue and if the selects the type of issue as Issue then i need to stop the creation of hr case..
In the Record producer i written script like below.
new sn_hr_core.hr_ServicesUtil(current, gs).createCaseFromProducer(producer, cat_item.sys_id);
if(producer.type_of_issue == 'issue')
{
current.setAbortAction(true);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2021 02:09 AM
what if you do this?
new sn_hr_core.hr_ServicesUtil(current, gs).createCaseFromProducer(producer, cat_item.sys_id);
if(producer.type_of_issue == 'issue')
{
gs.addErrorMessage('Not allowed to submit');
return false;
}
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
08-09-2021 03:15 AM
I did tried with your code seems i am not able to able use return false;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2021 03:24 AM
I did tried like below, but seem the Record producer still getting created
acbc();
function acbc(){
if(producer.type_of_issue == 'issue')
{
//current.setAbortAction(true);
gs.addErrorMessage("Not allow ");
return false;
}
else{
new sn_hr_core.hr_ServicesUtil(current, gs).createCaseFromProducer(producer, cat_item.sys_id);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2021 03:29 AM
Hi,
just try to use return line
acbc();
function acbc(){
if(producer.type_of_issue == 'issue')
{
//current.setAbortAction(true);
gs.addErrorMessage("Not allow ");
return;
}
else{
new sn_hr_core.hr_ServicesUtil(current, gs).createCaseFromProducer(producer, cat_item.sys_id);
}
}
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
08-09-2021 03:36 AM
It is throwing an error but still it creating a record. I believe since it is a record producer return or return false does not stop the transaction it still continues the transaction and it creating a record