when description is empty abort the action on incident form.

Sagar_pawar
Tera Contributor

Hello All,

I want to check current description is empty or not if its empty is want to abort action .

Thank You.

(function executeRule(current, previous /*null when async*/) {

current.addNullQuery(current.getValue('description'));
current.query();
if(current.next())
{
current.setAbortAction('true');
gs.addInfoMessage(current.number+" description Empty");

}
else{
gs.addInfoMessage("u can submit record");
}

})(current, previous);

1 ACCEPTED SOLUTION

Pavankumar_1
Mega Patron

Hi @Sagar_pawar ,

If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

View solution in original post

7 REPLIES 7

KrishnaMohan
Giga Sage

Hi @Sagar_pawar ,

 

1)In your code there is a mistake current.setAbortAction('true').you mentioned true in string('true') but it should boolean(true) i.e current.setAbortAction(true);

Also you can abort action without using advanced script, please find below steps

1)use filter condition i.e description is empty 

KrishnaMohan_0-1673876344179.png

2) on action section, make active true  add message field and abort action field

KrishnaMohan_1-1673876452263.png

 

If this helps, please mark this as correct/helpful.

 

Thanks,

Krishnamohan

 

 

Hello, @KrishnaMohan I know how to achieve this functionality using configuration but I want to achieve the same function using customization by using addNullQuery and addNotNullQuery().

Thank You.

 

Hello @Sagar_pawar ,

1)In your code there is a mistake current.setAbortAction('true').you mentioned true in string('true') but it should boolean(true) i.e current.setAbortAction(true);

2) please refer the below link 

https://www.servicenow.com/community/developer-forum/null/td-p/2444301

 

2)In above thread second solution is optional.

 

If this helps, please mark this as correct/helpful.

 

Thanks,

Krishnamohan