client script onload to detect if a submit has been done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2022 04:22 PM
I have a client script of type onload that sets a variable to false
what I need is to detect if that variable was changed to true after a save/submit so that if so then it does not return to false in the onload
It should only be set to false when the form is loaded the first time they open the record, so if the record was already opened and a change to true was made to that field, then the field should remain true, but if they close the form and after they open it again, the onload should put it back to false.
in other words:
-if the form is opened the first time it must appear in false
- if an update is made to true, after the submit it must appear in true and the onload that changes it to false should not be executed
-should only be set to false the first time the form is opened
Does anyone have the solution please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2022 10:09 PM
you should not use onLoad client script.
Use default value in that variable configuration and set the default value to false
If user changes the value to true the latest value will be saved when user submits the form.
If the user again reloads the form the default value will set it to false again
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2022 12:25 AM
in fact the default value of that field is "No"
I did what you suggested but it doesn't work, because after saving the value to true and reloading the page, the value is still true and is not returned to false as you said
there must be another way that when the form is loaded for the first time the value is set to false
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2022 12:49 AM
is this for catalog or normal form?
share some screenshots
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2022 02:52 PM