- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2024 08:43 AM
For the approval step in the workflow of a catalog item, the approver needs to be selected based on the Requested For users' department. We have a list of approvers for each department. I have this need for multiple catalog items and the list if different for each item. What would be the best way to handle this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2024 11:06 AM
Hi @Anu_Arv ,
You can use the "Approval User" activity to trigger approval dynamically based on the department. Assuming that department field in your user table is reference type store it in a variable and compare it with the departments you have in the catalog, if it matches in the loop you can push the approvers to the answer array.
As a best practice do not hard-code the sys_id's in scripts , please store the sys_id's in system properties as in the last else if condition
Example Code -
answer = [];
var user_department = current.requested_for.department;
if (user_department == "090eecae0a0a0b260077e1dfa71da828"){ // if user department is XYZ
answer.push('38fa64edc0a8016400f4a5724b0434b8'); // set sys_id of the XYZ department approver
} else if (user_department == "123a64edc0a8016400f4a5724b0434b8"){ // if user department is ABC
answer.push('098064edc0a8016400f4a5724b0434b8'); // sys_id of the ABC department approver
} else if (user_department == gs.getProperty("HR_Department_ID")){ // if user department is HR
answer.push(gs.getProperty("HR_Department_Catalog_Approver")); // sys_id of the HR department approver
}
If the solution shared works for you, please "Accept as Solution" and mark " Helpful."
Thanks,
Gummagatta Harshavardhana
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2024 11:06 AM
Hi @Anu_Arv ,
You can use the "Approval User" activity to trigger approval dynamically based on the department. Assuming that department field in your user table is reference type store it in a variable and compare it with the departments you have in the catalog, if it matches in the loop you can push the approvers to the answer array.
As a best practice do not hard-code the sys_id's in scripts , please store the sys_id's in system properties as in the last else if condition
Example Code -
answer = [];
var user_department = current.requested_for.department;
if (user_department == "090eecae0a0a0b260077e1dfa71da828"){ // if user department is XYZ
answer.push('38fa64edc0a8016400f4a5724b0434b8'); // set sys_id of the XYZ department approver
} else if (user_department == "123a64edc0a8016400f4a5724b0434b8"){ // if user department is ABC
answer.push('098064edc0a8016400f4a5724b0434b8'); // sys_id of the ABC department approver
} else if (user_department == gs.getProperty("HR_Department_ID")){ // if user department is HR
answer.push(gs.getProperty("HR_Department_Catalog_Approver")); // sys_id of the HR department approver
}
If the solution shared works for you, please "Accept as Solution" and mark " Helpful."
Thanks,
Gummagatta Harshavardhana