current.setAbortAction(true) is not working properly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2020 05:42 AM
I have on before business rule as below.
var val=current.getValue("abc");
var env=current.getValue("def");
var va = new GlideRecord("u_sap_transport");
va.addQuery("u_transport_number",val);
va.addQuery("u_environment",env);
va.query();
if (va.next()) {
current.setAbortAction(true);
}
The above code is working for Submit and Save ui action, but when user is clicking "insert and stay" and "insert", action is not aborting and record is getting created.
Can some one help how to fix this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2020 05:53 AM
Hi Krishna,
the script which you have written should work fine you don't need to change the code. If it is working on save button then it should work.
Make sure that you have written this on before insert
and try to put some logs to check where it is getting.
var val=current.getValue("abc");
var env=current.getValue("def");
gs.addInfoMessage('@ val '+ val+' @ env '+ env);
var va = new GlideRecord("u_sap_transport");
va.addQuery("u_transport_number",val);
va.addQuery("u_environment",env);
va.query();
if (va.next()) {
gs.addInfoMessage('@inside');
current.setAbortAction(true);
}
Mark helpful and correct if it helps.
Thanks,
CB

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2020 05:59 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2020 06:04 AM
Hi Krishna
In addition to the Script given by bhagyashree,please check this too.
SetAbortAction is not working if it`s in a BR in Scoped App and it is executed against the Global Scope table.
To abort action on out of scope (may be Global or any other scope tables), use "Abort Action" checkbox available in Actions tab of Business Rules. You will be getting just condition only in Advanced tab but you can call script include there.
Please Mark Correct and Helpful
Thanks and Regards
Gaurav Shirsat