List Collector passed values

dev_K
Tera Contributor

Hi,

 

 

I would like to see in what format, after the request submission the values of a list collector are passed.

 

Let's say here:

dev_K_0-1717675810708.png

 

 

How can I retrieve the values selected by user when using  grReqItem?

 

var userConsumers = grReqItem.variables.consumer;
Will consumers will be an array, a string with coma seperated values?
 
 
I use it in the catalog task configuration.
 
 
Thanks!
1 ACCEPTED SOLUTION

dhanrajb
Tera Guru

Hi ,

 

I think, you will get the (string) comma seperated sys_id(s).

 

Regards,

Dhanraj.

View solution in original post

9 REPLIES 9

You will need to loop the sys_id's of the consumers (so push those to your array) through the variables to see if any of them is in there. It can be done, but you will need to do it on sys_id.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Can you elaborate please? Not sure how to proceed. Many thanks!

Hi Dev,

 

You can use the for loop method to check this values in both the array. Below I have pasted the code snippet.

 

var consumers = ['example1', 'example2', 'example3'];
var userConsumers = 'example1,example5';//lets say for an example you are getting these values in userConsumer.
var userConsumerSplit = userConsumers.split(',');
var userConsumerArr = [];
userConsumerArr.push(userConsumerSplit[0], userConsumerSplit[1]);
for (var i = 0; i < userConsumerArr.length; i++) {
    for (var j = 0; j < consumers.length; j++) {
        if (consumers[j] == userConsumerArr[i]) {
            gs.info('Consumer found = '+userConsumerArr[i]);//replace with your steps.
        } else {
            gs.info('No Consumer found')//replace with your steps.
        }
    }
}

 

Regards,

Dhanraj.

dev_K
Tera Contributor

but here you are assuming the values: 

var userConsumers = 'example1,example5'

and what we need it to retrieve them by using: grReqItem.variables.consumer.

 

Those values are passed after submission on a catalog item request.

 

Thanks!

var userConsumers = grReqItem.variables.consumer;

Yes you can use "grReqItem.variables.consumer", to retrieve the values from the requested item variables. I just assumed the values to show the example string data. 

 

If my answer is not relevant to your question, please elaborate your question. I will try to resolve.

 

Regards,

Dhanraj.