- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2021 09:07 AM
Is there the possibility to perform dot walking when checking a variable of a ticket, if the variable is a referenced list collector?
i.e. if I have a normal reference, i can get the values i need by doing something like:
current.variables.VariableName.ColumnNameOfReferencedTable
Is there a way/method to do something like that, maybe in a for loop, for the list collector type?
current.variables.ListoCollectorVariableName[i].ColumnNameOfReferencedTable
or the only way would be to split the string and then perform a glide record for each one of the sys_id inside the variable?
Thank you.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2021 09:34 AM
Dot walking is not possible. We use something like this to populate a text variable with a comma-separated list of CI Names for each CI selected in a list collector on the cmdb_ci table
var cinamelist = [];
var cis = current.variables.v_ci.toString();//name of your list collector variable
var ci = new GlideRecord('cmdb_ci');//name of your List table
ci.addQuery('sys_id', 'IN', cis);
ci.query();
while(ci.next()){
cinamelist.push(ci.name);
}
current.variables.v_cinames = cinamelist.join(',');
or you use a for loop on the array of sys_ids
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2021 09:30 AM
It is not possible to dot walk because it can contains the multiple records.
Yes, you have to do the hard way - the only way would be to split the string and then perform a glide record for each one of the sys_id inside the variable.
You can use following query
gr.addQuery('sys_id', 'IN', current.getValue('current.variables.ListoCollectorVariableName[i]));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2021 09:34 AM
Dot walking is not possible. We use something like this to populate a text variable with a comma-separated list of CI Names for each CI selected in a list collector on the cmdb_ci table
var cinamelist = [];
var cis = current.variables.v_ci.toString();//name of your list collector variable
var ci = new GlideRecord('cmdb_ci');//name of your List table
ci.addQuery('sys_id', 'IN', cis);
ci.query();
while(ci.next()){
cinamelist.push(ci.name);
}
current.variables.v_cinames = cinamelist.join(',');
or you use a for loop on the array of sys_ids
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2021 10:07 AM
Thank you, just as I though, I hoped for some magic embedded servicenow method, that's why I asked 🙂
Thank you for the prompt answers!!