logo

NJP

Article #14 - Additional "Approval - User" Workflow Activity Exit Condition

Import · Nov 04, 2020 · article

Hi

Did you ever wanted to allow your Approval end-users to exit the "Approval - User" Workflow Activity with another option except "Approved" or "Rejected"?

Maybe you wanted your Approval users to offer the option like

  • "No longer Required", which e.g. would "CANCEL" the Approval for any reason, but NOT to be rejected to approved. Maybe you want to distinguish the outcome by having this option
  • "More Information Required", which may be needed, if the Approver does not have enough information to decide on the Approval.

The OOB "Approval - User" Workflow Activity just offers the "Approved" and "Rejected" Exit Condition, which are not sufficient in such a case.

What you will learn in this article

In this article, I will show you, how to add two new Exit Conditions to your "Approval - User" Workflow Activity in your workflows and what to do, to make them work as expected.

Steps to go:

  1. Add the desired Exit Conditions to your "Approval - User" Workflow Activity in your workflow
  2. Add a Script to the Properties of the "Approval - User" Workflow Activity to react to the new conditions
  3. Copy an existing OOB Business Rule to fire on the new state values of the Approval record
  4. Do a test-drive and enjoy the outcome image

!!! ALWAYS TRY OUT FIRST IN NON PRODUCTION INSTANCE !!!

1. Add the new "Exit Condition" to your Workflow in the "Approval - User" Activity

In my example, I add TWO new exit conditions ("No longer Required" and "More Information Required").

Go to the workflow where you want to add the new condition and open that workflow in Edit-Mode.

In Workflow Editor, right-click in the white area below the green header of the "Approval - User" Workflow Activity (like shown in the screenshot below), and select "Add Condition"

image

Configure the first additional Condition as shown in the below screenshot:

image

Configure the second additional Condition as shown in the screenshot below:

image

2. Add a Script to the Properties of the "Approval - User" Workflow Activity

Open the Workflow Activity Properties for the "Approval - User" Activity and change the Condition for approval to Script (see details in the screenshot below).

Add the script as I did in the screenshot to react to the new states:

image

3. Cope the OOB Business Rule "SNC - Run parent workflows (Approval)

Navigate to the Business Rules list in the backend and search for the Business Rule shown in the screenshot below.

NOTE:

To select the one Business Rule with the "Order = 100" (because there are TWO BR with the same name!)

image

Change the NAME of the BR (similar to that what I did in the screenshot below).

image

Right-click the header and click "INSERT AND STAY" (do NOT select SAVE to overwrite the OOB BR !!!)

Change the "Condition" as shown in the screenshot above and SAVE.

NOTE:

That new Condition makes the NEW Business Rule trigger when the Approval was changed to "not_required" OR "more_info_required". The Business rule "nudges" the Workflow to advance when the state of the Approval Record changes. Without this Business Rule, the Workflow would not be "informed" about any decision done for the "not_required" and "more_info_required" states.

4. Test-Drive and Enjoy

Now, test the changes.

Create a new record, that fires your workflow. My Test-Workflow looks like shown in the screenshot below:

image

Setting the Approval to (e.g.) "More Information Required" now nudges the Workflow to advance:

image

The workflow now advances to the given path.

image

WRAP UP

You do not change any OOB functionality as you COPY the existing BR and change it accordingly.

You need to do that for every single "Approval - User" Workflow Activity, that you place in your workflow, but you can adjust according to your business needs.

Let me know if you have any doubts, questions, or comments on this article.

Any additional information is welcome.

Thank you for reading, and I hope you enjoyed this article.

Please provide your feedback on this article in the comments below.

If you like it, just mark this article as helpful and bookmark it using the "Bookmark" button above for later access.

Have fun and built something on ServiceNow!

Dirk

---------------------------------------------------------------------

If you like to also review my other articles on the ServiceNow Community, please have a look at the overview here:

Overview of my articles

NOTE: The content I provide here is based on my own experiences and does not necessarily represent my employer's views.

View original source

https://www.servicenow.com/community/now-platform-articles/article-14-additional-quot-approval-user-quot-workflow-activity/ta-p/2312829