current.setAbortAction(true) is not working properly

Krishna Chaitan
Tera Expert

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

3 REPLIES 3

Chander Bhusha1
Tera Guru

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

Bhagyashri Sort
Kilo Guru

Hi Krishna,

 Try by replacing next with hasNext in if block. Below script is working fine for me.

find_real_file.png

Mark it correct and helpful.

Thanks

Bhagyashri Sorte.

Gaurav Shirsat
Mega Sage

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