Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

Manal  AQUIL
Tera Contributor

@rakesh8 I hope you are trying to auto-populate on the change of incident field.

 

 

rakesh8
Tera Contributor

Hey @Manal AQUIL 

I created 2 variables for a particular item, in which when i choose certain incident record in incident create variable( reference type), the watchlist of that particular incident record should be autopopulated in the watchlist variable( list collector type)

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

 

thank you @kamlesh kjmar its working 😄

Can you please give me a gist of the code. Just trying out scripting .

thank you