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.

How to populate Additional comments based on RITM variable value

AnilM99
Tera Expert

Hi Team,

I need to populate additional comments to "This request is pending for device status availability." when the RITM variable "Device Status" changes to 'Check Availability'.

I am trying Onchange client script, but no luck.

 

Help with the script

 

Thanks

Anil!

6 REPLIES 6

sumanta pal
Kilo Guru


Sure, you can use an OnChange client script to achieve this. Here's a sample script:

javascript
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
if (control.id == 'device_status' && newValue == 'Check Availability') {
g_form.setValue('additional_comments', 'This request is pending for device status availability.');
}
}


Here's the step-by-step implementation:

1. Navigate to System Definition > Client Scripts in your ServiceNow instance.
2. Click on New to create a new client script.
3. Fill in the fields:
- Name: Give a meaningful name to your script.
- Type: Select OnChange.
- Table: Select the table where your RITM resides.
- Field name: Select the field 'Device Status'.
4. Paste the above script in the Script field.
5. Click on Submit to save the changes.

Remember to replace 'device_status' and 'additional_comments' with the actual field names in your instance.


nowKB.com

AnilM99
Tera Expert

Hi guys,

Thanks for the quick reply.

I added the catalog client script to the catalog item, and it's working fine.

 

Thanks

Anil!