
- 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 09:31 AM
Can you clarify on the var locationName = current.requested_for.location.getDisplayValue().split("-").[0].trim();
It's not liking the [0].
I can't test the rest yet as i'm pulling in the code error.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2016 09:35 AM
Derek,
You will have to remove the dot(.) after split. Your line will be
"var locationName = current.requested_for.location.getDisplayValue().split("-")[0].trim();"
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:09 AM
Thank you! moving progress so far!
The trimming works on the user location.
I should additionally clarify that I am trying to pull a field from the result fo the record that they selected in the list collector.
So if USA - Fort Wayne and USA - New York is chosen, I would like the description from the selection. I tried to dot walk, but it is not liking it.
Do I have to put in a query on the results or should dot walking work? Here is what I have done.
var allSelected = current.variables.groups.description.split(",");
groups is the variable name of the list collector and description is the field that has the information I need.
Any thoughts?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2016 10:16 AM
what table is the "groups" list collector variable referencing?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2016 10:21 AM
sys_user_group (default group list table)