Approval issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2024 10:56 PM
Hello Experts,
We have two variables based "1" 2nd variable choice list will visible and its a List collector variable.
2nd variable choice lists created on the application table "cmdb_ci_appl".
Requirement
1We want to add approvals based on the name and managed by approval in workflow.
2nd variable name - "er_request_applications"
Choice list value
"name" and "managed_by" Please support to achieve this!
Approval user activity
var answer = [];
answer.push(current.variables.er_request_applications.name.managed_by);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 05:18 AM
I'm not sure if I'm understanding completely, but it sounds like your er_request_applications variable is a list collector, and you want to add an approval for each application selected, to go to the person who is the Managed by for the application. Your approval user activity script would need to look like this:
var answer = [];
var appl = new GlideRecord('cmdb_ci_appl');
appl.addQuery('sys_id', 'IN', current.variables.er_request_applications);
appl.query();
while (appl.next()) {
answer.push(appl.managed_by);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 01:42 PM
Hi @Brad Bowman
Thanks for the Quick reply!
Its working fine foe the single selection.
"er_request_applications" variable is user can select multiple values.
so we want to send approval for all managed by
please support.Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 07:27 AM
Sorry, missed one thing. When pushing a sys_id to an array, we must always force it to a string, or the same sys_id gets added to the array. Something about it pushing the memory location instead of the actual sys_id value:
var answer = [];
var appl = new GlideRecord('cmdb_ci_appl');
appl.addQuery('sys_id', 'IN', current.variables.er_request_applications);
appl.query();
while (appl.next()) {
answer.push(appl.managed_by.toString());
}