2nd level Approval
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2022 07:26 AM - edited 12-22-2022 02:33 AM
I need to trigger 2nd level Approval
second level Approval should be triggered to “ABC Group" and this group users should also be part of “Assignment group” selected in the First level Approvals, could anyone help me out to trigger 2nd level Approvals
for Example, if there are 20 approvers in 1st level Approval Group and 30 approvers in 2nd level approval group, the second level Approval should trigger only to the users who are part of 1st level approval group...
this script is not working
var index;
var answer = [];
var gr = new GlideRecord('sn_vul_vulnerable_item');
//if (gr.get(current.vul_record)) {
if (gr.get(current.vul_record.toString())) {
var approvers = gr.getElement('cmdb_ci.u_bu_security_poc').split(',');//reference field from sys_user_group table
for(index=0; index<approvers.length;index++){
var grmemb=new GlideRecord("sys_user_grmember");
grmemb.addQuery(gs.getProperty('sn_vul.sn_approve_vr'),"IN",approvers);//system property is the group name sysid
grmemb.query();
while(grmemb.next())
{
var user = new GlideRecord('sys_user');
user.get(grmemb.user[index]);
answer.push(user.sys_id);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2022 12:09 PM
Hi, with no clear details of your context it's not possible for the forum to understand your configuration or exactly what you are trying to do or how. If you are looking to implement a structured multi-level approval process, then I would look at utilizing Workflow Approval coordinator.
Approval Coordinator workflow activity (servicenow.com)
Simple approvals in workflow - Support and Troubleshooting (servicenow.com)
|
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2022 02:09 AM - edited 12-22-2022 02:34 AM
I need to trigger 2nd level Approval
for example, second level Approval should be triggered to “ABC Group" and this group users should also be part of “Assignment group” selected in the First level Approvals, below mentioned script is not working as expected.
for Example, if there are 20 approvers in 1st level Approval Group and 30 approvers in 2nd level approval group, the second level Approval should trigger only to the users who are part of 1st level approval group...
this script is not working
var index;
var answer = [];
var gr = new GlideRecord('sn_vul_vulnerable_item');
//if (gr.get(current.vul_record)) {
if (gr.get(current.vul_record.toString())) {
var approvers = gr.getElement('cmdb_ci.u_bu_security_poc').split(',');//reference field from sys_user_group table
for(index=0; index<approvers.length;index++){
var grmemb=new GlideRecord("sys_user_grmember");
grmemb.addQuery(gs.getProperty('sn_vul.sn_approve_vr'),"IN",approvers);//system property is the group name sysid
grmemb.query();
while(grmemb.next())
{
var user = new GlideRecord('sys_user');
user.get(grmemb.user[index]);
answer.push(user.sys_id);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2022 02:31 AM
Your post still does’t clearly explain you configuration or issue. What is the result of your debugging /what doesn’t work as expected?
looking at your undocumented code and the syntax of user.get(grmemb.user[index]) your intention is not clear, perhaps you could just use grmemb.user.sys_id ? as I would expect the result to be the same sys_user record?
but I can’t quite understand the purpose of ‘index’ array or how it relates to your sys_user record query?
I would suggest you add logging/debugging starting at the beginning of your code and validate all variables and assumptions.