- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 05:53 AM
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:
How can I retrieve the values selected by user when using grReqItem?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 06:29 AM
Hi ,
I think, you will get the (string) comma seperated sys_id(s).
Regards,
Dhanraj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 06:56 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 07:01 AM
Can you elaborate please? Not sure how to proceed. Many thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 07:45 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 07:48 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 07:58 AM - edited 06-06-2024 08:04 AM
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.