How to set other approver state to "No Longer Required" if one Approver is approved the request

Arun N P
Kilo Contributor

Through my app I am approving the Request approvals by running a SNOW REST script.

I am changing the approve state to "approved" by updating the table sysapproval_approver "state" filed.

var gr = new GlideRecord("sysapproval_approver");
 gr.state = action;

But at the same time i need to set all other approver status to "No Longer Required" through my REST script.

Can anyone please help me on this issue.

thanks in advance

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Arun,

I believe you will have to query the sysapproval_approver table with the approval record and then one by one iterate over the record and update to No longer required the state value except for the one which is already approved

Can you share the script you are using?

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Thanks Ankur,

The Request will have more than one approver, the scenario is if any one approves the request, all other aproover state should change to "No Longer Required".

In my script I check if the same request number is passed by the front end application.

if(Id == gr.document_id.sys_id && reqN == gr.document_id.number) {

          // here action is parameter passed from application values will be "approved" "reject" etc
            gr.state = action; 
            gr.update();
            gs.info("request "+reqN+ " updated successfully.");
        }

After this I have to make other approval state to "No Longer Required". I looked into sysapproval_approver table with the approval record  I did not see the other approvers name.

Can you please provide more info on this

Sanjay Bagri1
Tera Guru

Hi ,

Go to workflow  and you can set the condition for approval activity : any one to approve it will set the no longer required after any one approve. 

Please mark the correct and helpful.

Thanks

sanjay b.

Hi,

I am not using any workflow to approve. I am doing this through script.

Service now documentation says:

Note: When an Approval Action activity is used to mark a task approved, the activity marks all pending approvals as No Longer Required. This activity behaves differently from Set Values or Run Script when used to set the Approval field's value.

I need to do through script.