How to script If a value has changed?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 02:26 PM
I need an onSubmit Client Script but I also need it to check if the 'State' field value has changed.
How can this be scripted?
Thank you,
Susan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 03:10 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 04:58 PM
Several validation checks with a pop up window for confirmation.
Need to use an OnSubmit Client Script becuase other UI actions are being performed, which are related.
In the onSubmit Client script - also need to do a validation on several values. Including to see if the State value has changed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 05:12 PM - edited 03-20-2024 05:13 PM
@Su522 thanks for the info.
You can save the initial value of the 'state' with a g_scratchpad variable via a Display Business Rule.
Then within the onSubmit client script, you can do something like:
if(g_scratchpad.initialState == g_form.getValue('state'))
For how to set up a g_scratchpad variable, refer to this article - https://www.servicenow.com/community/developer-forum/g-scratchpad-functionality-and-its-use/m-p/1772...
OR instead of a client script, you can use a Business Rule to compare the previous and the new value of the state.
Hope it helps, thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 05:36 PM
Thank you. I'll might try the scratchpad but I think I got it to work like this:
I dont think I can use a Before Update BR for this purpose bc I need a Pop Up window to confirm- Yes (continue processing) or Cancel. I'm using a GlideModal. The GlideModal is for client side... Thoughts?