
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2016 09:01 AM
Hi all
List collector results comparison question,
I'm looking to try to do a comparison of the first 7 letters of a user's record location field, ex abc1234
and then compare it to a list collector that the user has selected to see if any contain the same data. for example:
user1 is from usajersey -
(it's a string so the query needs to stop before the - example: usajersey - somecity)
they select from list collector a name like usaflorida - share \write. This is the friendly name , not the actual name that i'm using for comparision.
but I only need the first characters before the -, on both the list collector and the user to be compared.
(not quite sure how to trim it down to look before. I tried doing the search '-' with no luck. Any thoughts? I'll give my psuedo coding example.
var userloc = current.variables.requested_for.location;
userloctrim = trimmed value;
//I'm wanting to search the entire selected list for matches
if (current.variables.listcollector.toString().indexOf('userloctrim') > -1) {
workflow.scratchpad.match = 'true'
}
else
workflow.scratchpad.match = 'false'
So if it can't find the trimmed data from the user location it returns a false.
Any idea on how to approach this? Let me know if additional clarification is needed.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2016 10:29 AM
Derek,
you will have to query 'sys_user_group' table for this. Dot walking will not work. here is the script for that
var gr1= new GlideRecord('sys_user_group');
gr1.addQuery('sys_id','IN',current.variables.groups.toString());
gr1.query();
while(gr1.next()){
if(gr1.description.indexOf(locationName)==0){
workflow.scratchpad.match = 'true';
}
}
Thanks,
Abhinay
PS: Hit like, Helpful or Correct depending on the impact of the response

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2016 10:29 AM
Derek,
you will have to query 'sys_user_group' table for this. Dot walking will not work. here is the script for that
var gr1= new GlideRecord('sys_user_group');
gr1.addQuery('sys_id','IN',current.variables.groups.toString());
gr1.query();
while(gr1.next()){
if(gr1.description.indexOf(locationName)==0){
workflow.scratchpad.match = 'true';
}
}
Thanks,
Abhinay
PS: Hit like, Helpful or Correct depending on the impact of the response

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2016 10:49 AM
Question,
How about handling, if they chose both 1 and 2, apparently it still shows a match, which means it matches the first but not the 2nd, but triggers the matching status?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2016 12:49 PM
Derek,
I did not get your requirement. What is 1 & 2 that you are referring? Can you also paste the code you have right now.
Thanks,
Abhinay

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2016 12:54 PM
workflow.scratchpad.match = false;
var displayName = "";
//get the part of location value before "-"
var loctest = current.variables.requested_for.location.getDisplayValue(); //works
var locationName = current.variables.requested_for.location.getDisplayValue().split("-")[0].trim(); //works
//get all the selected locations from the list collector
var allSelected2 = current.variables.groups.description;
var allSelected = current.variables.groups.description.split(",");
//check for each selected value from the list collector
var gr1= new GlideRecord('sys_user_group');
gr1.addQuery('sys_id','IN',current.variables.groups.toString());
gr1.query();
while(gr1.next()){
if(gr1.description.indexOf(locationName)==0){
workflow.scratchpad.match = 'true';
}
}
The issue is, if user submits for A and B and the user is from A,
It sees the match first, and stops, doesn't continue checking to see if there are any B's in the string.
It only sees the first match and states it's a match when it's not a complete match.
That's the simplest thing I can explain it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2016 01:24 PM
For example, if a user belongs to 3 groups, then all the 3 group's description should contain the locationName. If 3 matches are found then you need the match to be true or else false. Is that correct?