The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Client Script Set Value to null or ""

conradw
Kilo Contributor

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

5 REPLIES 5

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

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


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


conradw
Kilo Contributor

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