Print query results to field

shembop
Tera Contributor

        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.

7 REPLIES 7

shembop
Tera Contributor

I would say the issue with the related list is it would populate on every catalog task needed, or not.


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


you can add list controls to make it visible when you want it to be