Print query results to field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2017 01:55 PM
So, I am looking to get a list of all CI's associated to a user and print it into a task field. Maybe the Description field, Maybe Work Notes. I have not decided.
What would be the easiest way to do that? The goal is to provide a list of machines without making the person go hunt through a related list. I could print out the task and tell a person to go forth and conquer.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2017 02:11 PM
I would say the issue with the related list is it would populate on every catalog task needed, or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2017 12:21 AM
Hi,
Within the Catalog Task activity, check Advanced under scripts and add a code to retrieve the CI related to the requester. Ity would be something similar to,
var userCI= [];
var gr = new GlideRecord('cmdb_ci');
gr.addActiveQuery();
gr.addEncodedQuery('assigned_to='+current.variables.requested_for);
gr.query();
while(gr.next()) {
userCI.push(gr.getDisplayValue() + ' '); //add which ever field you want to display in description.
}
task.description = userCI.join(','); // change it to task.work_notes if you wish
Darshak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2017 06:01 AM
you can add list controls to make it visible when you want it to be