Auto populate watchlist

rakesh8
Tera Contributor

Hi guys,

I got two variables in service catalog,

incident created: ref type

watchlist: list collector

I want to autopopulate the watchlist based on the incident record that i choose. Can i get some hints or sol for this

thank you

1 ACCEPTED SOLUTION

Hi @rakesh8 ,

 

Try the below client script code on change of your incident variable:

 

 

var inc= g_form.getReference('your_incident_variable_name', populateWatchList);

function populateWatchList(inc) {
       g_form.setValue('your_watch_list_variable_name', inc.getValue("watch_list");
    
}

 

 

I hope this help.

 

Please mark this helpful if this helps and Accept the solution if this solves your issue.

 

Regards,

Kamlesh

 

View solution in original post

9 REPLIES 9

@rakesh8  I am glad, it helped.  Below inline is the explanation of code used.

 

var inc= g_form.getReference('your_incident_variable_name', populateWatchList); //Get the reference of the selected incident record Asynchronously and pass it to the  'populateWatchList' callback function

function populateWatchList(inc) {
       g_form.setValue('your_watch_list_variable_name', inc.getValue("watch_list"); //Inside the callback function we are retreiving the value of the selected incident's watchlist field and populating the watchlist variable of the catalog item.
    
}

 

 

I hope this helps.

 

Regards,

Kamlesh

Thank you so much ^^

@rakesh8 

 

1.Create an onchange client script on change of incident.

2. Use below script: 

 

var incRecord = g_form.getDisplayBox('incident backend name').value;
g_form.setValue('watch_list' backend name', incRecord );

 

rakesh8
Tera Contributor

Its not working @Manal Aquil . i applied what you said in the catalog client script with on change variable as incident created

@rakesh8 I don't see you are using below script :

var incRecord = g_form.getDisplayBox('incident_created').value;
g_form.setValue('watchlist', incRecord );

 Mark helpful if it works