Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

setAbortAction is not working in Scoped application

shaik_irfan
Tera Guru

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);

}

find_real_file.png

 

@Ankur Bawiskar  can you please help me on this

30 REPLIES 30

@shaik.irfan 

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

 

I did tried with your code seems i am not able to able use return false;

 

@Ankur Bawiskar 

 

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);
}

}

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

 

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