Display value in ListCollector based of multipe conditions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2024 10:31 PM
Hi All,
I have a list collector variable on form for which look up table is say 'internal table'.
The variable should display values based on below conditions.
1) If requester is part of VIP department then ------> display all the device from 'Internal table' which has 'availablility' -- 'available', 'not available','both'.
2) If requester is not part of VIP department then ----> display only devices which has availability ---- 'available', 'both'.
i have configured the below condition for 2nd part but i am not sure how to include the first condition.
javascript: 'availability=both^ORavailability=available^u_status=active^' + "u_brand="+current.variables.preferred_brand;
Can anyone suggest how to filter data using both of the conditions 1 and 2.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2024 10:21 PM
Hi @Sonam_Tiwari ,
I tried configuring the below. Can you please guide me...
If this works fine all good else i will try using above code shared by you.
Ref qualifier:
javascript:new userUtils().getUserData(current.variables.requested_for,current.variables.preferred_brand);
Script Include:
getUserData: function(requestedFor,prefBand){
var reqUser = requestedFor;
var brand = prefBand;
var execUser = new GlideRecord('sys_user');
execUser.addQuery('sys_id', reqUser);
execUser.addQuery('department','eebea758dbd763c0f049e126059619b9');
execUser.query();
if(execUser.next()){
var eUser = true;
}
else{
eUser = false;
}
var dev = new GlideRecord('u_custom_devices');
dev.addQuery('u_brand','brand');
dev.addQuery('u_status', 'active');
if(eUser == true){
dev.addEncodedQuery('u_availability=both^ORu_availability=available^ORu_availability=notavailable');
}
if(eUser == false){
dev.addEncodedQuery('u_availability=both^ORu_catalog_availability=available')
}
dev.query();
if(dev.next()){
return ----------------> Not sure how to return values here.... i want to return device Model based on above conditions
}
},
Can you help with this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2024 10:44 PM
Hi @sanvi ,
I think, the model should be reference here and you want to pull and show all those models? If so,
Replace
if(dev.next()){
return ----------------> Not sure how to return values here.... i want to return device Model based on above conditions
}
with
var sysIds = []; // the array that will hold the list of models returned after querying
while (dev.next()) {
sysIds.push(dev.getUniqueValue()); //getting the sysids
}
return sysIds;
and in your qualifier you may include 'sys_idIN'+ in the beginning. So if the sys id is in the returned list from script include, it will be available in the list collector for selection.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2024 03:59 AM
Hi @Sonam_Tiwari ,
I will make the changes in my script as per above and get back.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2024 10:52 PM
Hi @Sonam_Tiwari ,
I change the script as above, but it does not seem to be working.
I am not getting any values in the list collector.
NOTE: Model is not a reference field in the custom table its a string. Is it happening because of that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2024 11:29 PM - edited ‎01-16-2024 11:48 PM
Yes,
You will have to return the sys ids of those records from the table to which your list collector is referencing.
Is your list collector pointing to u_custom_devices?