Client Script Set Value to null or ""
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2015 08:24 AM
Hi all,
Have a onLoad client script that sets a couple of fields to empty on the incident form. It works fine for normal text fields but when I use it to set a list field i.e watch_list to empty/blank/null then when the form loads and you don't make any other changes, then you are prompted with the usual prompt "would you like to navigate away from this page" even though you have made no changes.
Any ideas, how to work around this?
Thanks
Conrad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2015 08:43 AM
Hi,
You may find the below thread as helpful.
http://www.servicenowguru.com/scripting/client-scripts-scripting/custom-dirty-form-message/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2015 12:58 AM
Thanks Pradeep, that helped me in the right direction. I added "g_form.modified = false" after I cleared out the list field in the client script to indicate the form had not been modified.
Regards
Conrad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2015 07:26 AM
Hi Conrad,
We are trying to do the same in our instance. We have a True/False tick box and if it is ticked we need to remove all the Watch list and Work Notes list users. At this stage it keeps failing and want to know if you ever got it working.
Thanks,
Lucien
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2015 08:12 AM
Hi Lucien,
I never had a problem clearing the list, you use g_form.setValue('watch_list', '') in a client script, however it marks the field as having been updated which you probably dont want if its in an onload script, thats where the g_form.modified = false;, which sets the form as having not having been updated and then doesn't require a save to navigate away.
Conrad