How to populate Additional comments based on RITM variable value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2024 12:47 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2024 01:45 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2024 03:12 AM
Hi guys,
Thanks for the quick reply.
I added the catalog client script to the catalog item, and it's working fine.
Thanks
Anil!