Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

I have a requirement to reset the form fields to empty when UI Action 'Reset to Draft'

Trupti Krishnam
Tera Contributor

I have a requirement to reset the form fields to empty when UI Action 'Reset to Draft' .There is a UI Action button in the demand table that appears when the state changes to submitted or screening or qualified and for the rest of the stage when i click on reset to draft UI action all the form fields except the number has to set to empty.Please help me to achieve this

 

8 REPLIES 8

J Siva
Kilo Patron
Kilo Patron

Hi @Trupti Krishnam 
I recommend creating a new "After Update" Business Rule to clear the field values, instead of modifying the OOB UI Action script.
This approach ensures that if you ever want to revert to the original OOB functionality, you can simply deactivate the custom Business Rule without affecting the default behavior.

Regards,
Siva

jameswoodfo
ServiceNow Employee
ServiceNow Employee

I was looking through the recommendations that you've gotten but would recommend against doing this as a UI Action. I would leave the current UI action as is and use an update business rule that looks to see if the state has changed to draft.

 

That being said, I do have a question for you: what is the actual business need for clear all of the fields except for number? Seems like you are going to lose a lot of information.

Principal Technology Consultant, Expert Services, CTA/CIS+

kaushal_snow
Giga Sage

@Trupti Krishnam ,

 

You can create a UI Action (with both client and server logic) on the demand table named Reset to Draft so that when users click it, a client script clears the visible form fields using g_form.clearValue('field_name') or g_form.setValue('field_name', '') for each field you want reset, and then the server side portion (in the Script section of the UI Action) resets the current record fields (except the number) to blank or null then updates the record and redirects back to edit mode, thereby giving users an immediate blank form view and persisting the reset on the server....

 

If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.

 

Thanks and Regards,
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/

phil_bool_unifi
Tera Guru
Tera Guru

@Trupti Krishnam , I'd enourage you to take care before following the advice you've been given, just as James says.  The purpose of the 'Reset to Draft' action is not to clear out the record so the proposal begins its entire journey again - that would be achieved just by using the option to create a New Demand.  Reset to Draft as it works today is a really useful step. 

Imagine a Demand is approved, but you realise the circumstances surrounding the demand changes a month after it went into the pipeline.  Reset to Draft would reflect you needing to look again at the decision.

If you need your submitter to start again from scratch, reject the demand and ask them to submit a new one.  The Demand Number is not a critical piece of information - there would be no benefit to maintaining it.