Workflow utility "Approval - User" stalls on state... - ServiceNow Community
Mark Roethof
Tera Patron
Tera Patron

Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

 

Workflow Editor is a legacy product to maintain existing workflows already in production. For new use cases and workflows, use ServiceNow Workflow Studio. Workflow Studio is a low-code alternative to Workflow Editor.

 

Hi there,

 

When working with Workflows and Approvals, the majority of the states used for the Approvals will be "Approved" or "Rejected". In some rare cases, "No Longer Required" could apply. Did you also encounter, that when applying the "No Longer Required" state the "Approval - Group" activity does go on while the "Approval - User" workflow activity stalls?

This is an out-of-the-box issue (also still valid in Orlando). After some investigation, I came up with a small and low impact workaround.

Approval - User

To explain our case, let's set up a minor Workflow. A Workflow only containing an "Approval - User" utility.

 

find_real_file.png

 

While triggering this workflow (for example with a Catalog Item), an Approval record will be created. When you would simply approve or reject the generated Approval record, the Workflow proceeds. Though, when changing the state to "No Longer Required"…

 

find_real_file.png

 

Upon performing a "Nudge" on the Workflow context, the Workflow does proceed.


Business Rule

While investigating this issue, I quickly encountered that this issue does not exist for the "Approval - Group" Workflow activity. Immediate thoughts going to the actual code of both Workflow activities, and also server side script like Business Rules.

Diving into Business Rules and looking at the Conditions, pretty quickly one Business Rule stands out concerning Group Approvals: "SNC - Match state to approval". While testing, and deactivating this Business Rule, also the Group Approval does not proceed anymore.


Workaround

The code used within the Group Approval Business Rule is not what we are after for fixing the User Approval. Though, it does tell us to handle this server-side, for example with a Business Rule. Also we already noticed, that when nudging the Workflow context, the Workflow does proceed.

So, let's set up an after update Business Rule which nudges the workflow.

When to run
When: after
Update: true
Filter Conditions: State | changes to | No Longer Required

Script

(function executeRule(current, previous /*null when async*/) {

	var wf = new Workflow();
	var ri = new GlideRecord(current.getValue('source_table'));
	
	if(ri.get(current.getValue('sysapproval'))) {
		wf.runFlows(ri, 'update');
	}

})(current, previous);


Result

After triggering our Workflow once again, and manually changing the state of the Approval to "No Longer Required"… the Workflow now proceeds immediately 🙂

---


And that's it actually. Hope you like it. If any questions or remarks, let me know!

 

C

If this content helped you, I would appreciate it if you hit bookmark or mark it as helpful.

 

Interested in more Articles, Blogs, Videos, Podcasts, Share projects I shared/participated in?
- Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

 

Kind regards,


Mark Roethof

ServiceNow Technical Consultant @ Quint Technology
1x ServiceNow Developer MVP

1x ServiceNow Community MVP

---

LinkedIn

Comments
S M
Tera Contributor

Hi Mark,

Thank you for this great article, Is it working on Change Policy approval As a group approval?

I am trying to use the "No Longer Required" UI Action which set the state to "No Longer Required" but I am facing 2 main problems:

  1. When all of the group approval members are completed their approval or "No Longer Required" the group approval stays as requested and the approval not changing to approved or No Longer Required. This is making the Workflow stuck and not proceed with the rest of the Teams.

  2. When the Manual approval selecting the "No Longer Required" state the workflow stuck again and not changing the Change state and the approval state in Change.

Do you have any idea how can I make the No Longer Required acting as the Approved state?

 

Best wishes,

Shay

ysconnect
Giga Contributor

Hi Shay,

Please let me know if you find the solution to your issue. As I am stuck with a similar issue.

Regards,

Yogesh

ericgilmore
Tera Guru

An absolute life saver.

Now I wonder why this wasn't fixed previously.

 

Anywho, cheers!

Version history
Last update:
‎08-03-2024 06:47 AM
Updated by:
Contributors