Approval issue

akin9
Tera Contributor

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);

 

 

akin9_0-1711518568454.png

 

 

3 REPLIES 3

Brad Bowman
Kilo Patron
Kilo Patron

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);
}

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!

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());
}