The CreatorCon Call for Content is officially open! Get started here.

Business rule to restrict approval

Phanideepthi
Tera Contributor

Hi All, 

There is a catalog item where once the request is submitted and waiting for approval. there are two check boxes on RITM form where any one should be selected before approving. here is the script

 

Phanideepthi_0-1682682289588.png

Here the issue is it is working for only one check box the or condition is not working. Please help to achieve this.

 

Thanks

9 REPLIES 9

@Phanideepthi 

that's what you want.

If any of the checkbox is checked the IF statement will be true and will throw error.

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

I did tried every possible condition, but it is not working as expected. In above script "revoked" option is added first so it is working fine if I check the check box and approve. But if I select the other check box for dates and approve the RITM it is throughing me the error.

 

My exact ask is user has to check any one of the check boxes before approving. Once selected anyone check box they should be able to approve.

David Holmes
Tera Contributor

Hi @Phanideepthi 

I think perhaps just changing the brackets around in the if condition may resolve this:

if ( (ritm.variables.this_variance_is_effective_until_revoked == 'false' || ritm.variables.this_variance_is_effective_within_the_following_duration == 'false') && ritm.cat_item == 'Server Variance')

Hope this helps

Hi David,

I did tried the script but not working.

Hi @Phanideepthi 

The check box holds a Boolean (true or false) value and the if condition above is checking for the string "false"... so you can do as Anker has stated above and set the variable toString() or remove the quotations from "false" so as to check for a Boolean rather than a string:

e.g. ritm.variables.this_variance_is_effective_until_revoked == false

Something you may have already tried to be fair.