Client Script onChange does not work first time around
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2023 03:53 AM - edited 08-14-2023 03:56 AM
I'm relatively new to ServiceNow Client Scripts. I'm trying to write a script that makes the 'comments' field mandatory specifically when incident 'state' changes to newValue In Progress (2), from oldValue New (1).
The script seems to work successfully, apart from when I initially change the state field. All subsequent state changes work as expected, just not the first.
Example: I open an incident which is in state New. I select 'In Progress' from the dropdown - State is not mandatory. I then select another state from the drop-down before reselecting 'In Progress' - only then does State become mandatory.
I have tested this in both a PDI (Utah) and my organisations dev environment (Utah). Both have the same outcome. I would appreciate some help with this. Many thanks.
Script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2023 01:42 AM - edited 08-15-2023 01:42 AM
That is weird.
I wonder if there is another script running at a latter order or a ui policy that overrides the comments field behavior