Wednesday, September 21, 2016

How to Use Client Script in Service Now ?



Client scripts are shipped to the client (the browser) and run there instead of on the server. Users who know JavaScript can define scripts to run in the client browser. Several types of scripts are supported

Requirement : Whenever any drop down list value changed, Populate the selected value of Drop down list value into another field

Eg : Whenever 'Device type' value modified, display the selected 'Device type' value in 'Name' field



Solution 
Create a client script as shown below screenshot

     var deviceType = g_form.getValue('device_type');
     var deviceTypeLabel=g_form.getOption('device_type',deviceType).text;
     g_form.setValue('name',deviceTypeLabel);




For More Info , Refer http://wiki.servicenow.com/index.php?title=Client_Scripts#gsc.tab=0

6 comments: