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.

Move Change Request backwards

vivek_f19
Tera Contributor

Hi there, 

I am looking to be able to move Change Requests backwards. It's set up to in the following path:
New -> Assess -> Authorize -> Scheduled -> Implement -> UAT/Verification -> Review -> Closed/Cancelled.

I need the following:
Assess -> New
Authorize -> New
Scheduled -> Assess

I built a UI Action that allows the CR to move from Assess -> New. This one works as expected. All good there.

vivek_f19_0-1763662261795.png
This is where I am having a hard time:
When I go from Assess -> Authorize, it generates an Approval and is set to Requested, as expected. 
Happy path: Approval is Approved, it goes to Scheduled. And we can move in the direction.

Issue: When I move click on Return to New  in the Authorize state, it cancels the Approval. I guess this isn't such a bad thing, but then when it's Approved again, it doesn't go to Scheduled the second time. i have to manually change the State for it to progress. I suspect this is due to the way the Change Request - Normal workflow is configured.

I also built a second UI Action called Return to Assess.

vivek_f19_1-1763663433811.png

Issue: With this one, multiple fails:
1. It moves the  progress bar to Assess -> GOOD
2. Throws a Invalid update error.
3. Sets the State to -5. 

vivek_f19_2-1763663583045.png


I've tried different things for this feature for the last 2 weeks and am really out of ideas. I would appreciate guidance and a solution to achieve this requirement. Thank you in advance.



1 REPLY 1

k_lutz
Tera Guru

Hi Vivek_f19,

The first thing I would think is that you may not be able to use the OOB workflow unless you are willing to have certain items retriggered like the approvals. What you can do is look at the script include called "Workflow". It has functions that can be used to retrigger the workflow. Even though you are changing the state, the workflow has already been "run" if you look at the contexts. There are functions like startFlow, runFlows, etc. that can be used. I believe one of the conditions will either keep approvals as they were are reset them for the next pass. There are different postings similars to yours like (https://www.servicenow.com/community/developer-forum/how-to-restart-any-workflow/m-p/2018306). I even remember seeing somewhere that people used the "rollback" activity in custom workflows to account for these but that would require more work that checking if one of these functions can be used in conjunction with your UI Actions.