CLient side validate CAB approvers

Lucky1
Tera Guru

Hello all,

 

Good day!!

My requirement is Change request when moved to CAB state, then only CAB approvers needs to edit a field (u_xyz)

So, for this I have written a Script Include and on Change Client script.

So, the script include will be returning an array consists of all sys_ids of CAB approvers.

And at on Change client script the answer is giving all these sys_ids as expected.

 

Now, I want to check one by one sys_id with the logged in user of service-now.

So, can someone tell me how can we do this?

 

 

Regards,

Lucky

5 REPLIES 5

Swapna Abburi
Mega Sage
Mega Sage

Hi @Lucky1 

have you tried an ACL for your requirement? From your requirement, i think field level ACL would be best fit.

 

If you want to go with client script and script include then you need to validate logged in user with your array of sys_ids in script include itself and return yes or no to the client script.

 

 

Yes Swapna,

 

If you want to go with client script and script include then you need to validate logged in user with your array of sys_ids in script include itself and return yes or no to the client script.

 

----> For the above one, can you give me logic please?

 

 

Regards,

Lucky

Sample logic:
var userID = gs.getUserID();
var approversArray = "{sysid1,sysid2,sysid3}"; //array containing sys_ids
if (approversArray.toString().indexOf(userID)>0){
    return 'yes';
}
else{
    return 'no';
}

Hello Swapna,

 

In the Approvals (sysapproval_approver) table, is there a way to get the groups where the approvals will be triggered to?

 

 

Because, for me the CAB approvals are getting triggered to multiple groups.

So, I want to return all those groups.

 

Regards,

Lucky