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
3 weeks 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
3 weeks 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
3 weeks 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
I checked and found there is no browser configuration that is triggering this reload dialog box. I checked on incident table from my current instance and it worked without any issue.
It's only when I'm using the action button on the custom form the dialog box appears.