Onload client script not working as expected on "Service Operations Workspace"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2023 02:43 AM
I wrote an onload client script on "incident" table to make remove some choices in the state field when the record is in in progress. The script is working fine on "Agent Workspace" but it is not working as expected on "Service Operations Workspace". Basically the choices are not getting updated.
For example:- When the record is in "On Hold" state only option available in the state field should be "in progress". but when we move from "On Hold" to "in progress" the available options should be "in progress" , " On Hold" and "Resolved" but the options available are "in progress" and " On Hold".
to make it work we have to reload the entire page manually after updating the record.
how can we make it work as soon as someone will save/update the form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2023 03:01 AM
Can you share the onLoad script.
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2023 02:43 AM
I won't be able to share the script but its just a simple on load client script which have else if conditions from which we are removing the state choices accordingly.
Regards,
Ansh Mahajan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2023 11:47 PM
Hi @Community Alums
Looks like the issue is in the client script,You can share some sample code by changing fields
Sample :
if (newValue == 'x')
{
g_form.clearOptions('company'); //clear all the options
g_form.addOption('company', 'pepsi', 'Pepsi', 1); //add the necessary options.
g_form.addOption('company', 'cocacola', 'CocaCola', 2);//add the necessary options.
}
else if (newValue == 'y')
{
g_form.clearOptions('company');
g_form.addOption('company', 'apple', 'Apple', 1);
g_form.addOption('company', 'samsung', 'Samsung', 2);
}
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 11:00 PM
Hi @Voona Rohila ,
Yes it is working fine but does it is recommended as ServiceNow technical best practice ?
Regards
Ansh Mahajan