Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Button to move policy exception back to draft when it expires

MarisaW81535484
Mega Contributor

Hello, 

 

I am trying to create a UI Action button that will appear when a policy exception expires and allow the user to move the policy exception record back to the 'New' state. I am unsure of how to do this as there is no expired state for the policy exception record there is only an Expired substate which is driven by the extensions. I do not want the button to be based on extensions. I also tried using a condition on the 'Valid to' field but this did not work because when the valid to date passes a new date must be input before being allowed to press any buttons or save the record. If anyone has done this or something similar before please let me know how I can achieve this. 

2 REPLIES 2

pavani_paluri
Tera Guru
Tera Guru

Hi @MarisaW81535484 ,

 

- Make the button appear only when the record’s “Valid to” date is already past.
(current.valid_to < gs.now())

- When clicked, the button resets the record’s state back to “New” and clears the expired substate.
current.state = 'new'; // or the actual value for "New"
current.substate = ''; // clear expired substate
current.update();
action.setRedirectURL(current);

- If needed, also clear the “Valid to” field so the system doesn’t block saving
current.valid_to = '';

 

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Pavani P

SanjivMeher
Mega Patron
Mega Patron

We have something similar. We provide user to Request extension when the exception is about to expire in 30 days or has expired. When they request extension, we provide them another record producer UI to enter the new plan and dates. Once they submit, it again goes for the usual approval process. We have a customized a lot, so may not match to the OOB flow.


Please mark this response as correct or helpful if it assisted you with your question.