Question on service catalog variables - checkbox and list collector

karrierr
Tera Contributor

We need to add a new variable in one of our service catalog items that will allow user to select multiple values in the choices. Aside from that, depending on the selected values, the system should determine the right Approver and generate an approval request to that person.

 

I believe that we can use a check box or list collector. However, if we use a check box, is there a way to not hard-code each value (because the values are around 50)? 

If we use a list collector, we can have a table-driven value displayed on it, but how do we get the values that user selected on the list collector and then map it to the table that we have containing the list of Approvers? Is this possible through scripting? Once we know who the required approvers are, the workflow should generate Approval requests for each selected value in the list collector.

Let me know if you have a similar requirement and kindly provide suggestions.

Thanks.

5 REPLIES 5

Saikiran Gudur1
Mega Guru

As you have good number of choices to deal with with, it is suggested to go with "list collector WITH reference as table"(the table that holds those 50 values).

Thanks,
Saikiran Guduri (NOW)
Associate Certificate Engineer | ServiceNow Store Apps
(Please mark the answer as correct answer/helpful/accept the solution if it helps)

Yes, list collector. But, how do we get the values that user selected on the list collector and then map it to the table that we have containing the list of Approvers? Is this possible through scripting? Once we know who the required approvers are, the workflow should generate Approval requests for each selected value in the list collector.

Trupti6
Tera Expert

Hi karrie,

From your requirement, the best thing for multiple selection is to use List collector,

To get the selected values of list collector use current.variable_pool.VARIABLE_NAME.getDisplayValue();

and try to write script as follows for approvals in approval activity.

 

answer =[];

var model = current.variable_pool.model.getDisplayValue();
var get_model = model.split(',');

for(i=0; i<get_model.length; i++){

if(get_model[i].trim()=='ABC' || get_model[i].trim()=='XYZ' ) {

answer.push('user1');
answer.push('user2');
continue;

}

if(get_model[i].trim()=='PQR'){
answer.push('user3');
continue;


}

Thanks,

Tripti S

 

karrierr
Tera Contributor

Hi Tripti,

 

Thanks for your response.

Based on the sample script you sent, does that mean I should hard-code the values and approvers in the script in order to generate the approval requests?

 

Regards,

Karrie