gliderecord for record created second before

Hafsa1
Mega Sage

I have this BR which I'm running whenever record in "approved", so that other group approvals get "no longer required".

But , just after 1st group approval , it triggers another approval and they are getting "no longer required" too just after creation.

 

Can we modify this code such that it should query only those approval record which are genereted 5 sec before current time?

As I have seen approval record are generated within 1 or 2 secs after 1st approval record is approved.

 
function renderTaskApprovalsMoot() {
        var gr = new GlideRecord('sysapproval_approver');
        gr.addQuery('sysapproval', current.sysapproval);
        var qc = gr.addQuery('state', 'requested');
        qc.addOrCondition('state', 'not requested');
        gr.query();
        while (gr.next()) {
            gr.state = 'not_required';
            gr.update();
        }
8 REPLIES 8

@Ankur Bawiskar 

we are adding multiple approval from BR . If one approves, other are not moving to "not longer required". Hence, written BR to manually change other approvals. But we have second level approval just after 1st level approval, which is triggerring to group.

Hence, need to change the query to get those approval record which were created earlier say (10 seconds) 

@Hafsa1 

Not an ideal way to create approvals.

Why not have flow or workflow for this and this capability will be OOB?

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

@Ankur Bawiskar 

this is existing BR, it was working earlier. But don't know what happened, after some patch upgrade it is not working now. 

Hafsa1
Mega Sage

NO group approval is done. Just triggering approval from BR