Client-side UI Action to clear form fields without page reload (New Record)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hi Community,
I am looking for support regarding a custom UI Action I created to reset a form.
Requirement: I have a "Reset Form" UI Action button that appears on the form before insertion (New Record). My goal is to clear all field inputs so the user can start over, but I want to stay on the current record context. I do not want to reload the page, as reloading seems to be initializing a new record/Sys ID rather than just resetting the current form.
The Issue: With my current code, the fields are cleared, but the browser triggers the "Reload site? Changes you made may not be saved" error. This suggests the script is trying to force a page refresh, which is not the desired behavior.
Configuration:
Client: True
Show Insert: True
The Code: Please see the script I am currently using below:
My Question: How can I modify my script to simply clear the field values on the client side without triggering a page reload alert?
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
but why are you using setValue() and not clearValue() since you want the value to be cleared
it worked for me with setValue() and no browser message
I checked in Firefox
Seems some configuration in your browser is doing this
But you should use clearValue() as setValue() might trigger some onChange client script
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
thank you for you support. i will have to check if there is any configuration that is messing with the browser and update accordingly
