We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Count number of approval

Hafila Hatta
Tera Guru

hi. i'm trying to determine how to determine number of approval in a REQ. what we are trying to achieve is, in requests with more than 1 approver, the ticket will auto cancel if there's no approval by approver 1 after a certain time.

1 REPLY 1

SN_Learn
Kilo Patron

Hi @Hafila Hatta ,

 

Please try the below in background script:

 

var reqsysID = 'ea87553b831b0210e1c15d10feaad36a'; //sysID of REQ record
var countAppr = 0;


var approverTab = new GlideRecord('sysapproval_approver');
approverTab.addQuery('sysapproval', reqsysID);
approverTab.query();
while(approverTab.next()){
	countAppr ++;
}
gs.info('Total Count of Approval Records: '+ countAppr);

 

 

Result:

 

*** Script: Total Count of Approval Records: 3

 

 

Mark this as Helpful / Accept the Solution if this helps

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.