How to trigger approval from flow designer

KARAN24
Tera Contributor

Hi Team,

 

Can anyone help me with Flow designer,I want to trigger an approval to specific groups,based on the logged in users' country,so there are around 11 countries and 11 groups and in future the countries can get increased,so how we can trigger the approval using flow designer,don't want to use so many if/else .

 

Thanks,

Karan

3 REPLIES 3

Michael Fry1
Kilo Patron

Perfect case for Decision table: https://docs.servicenow.com/bundle/utah-application-development/page/administer/decision-table/conce... 

You pass in value(s) from your record and when the criteria matches, that's the group it will use.

Karan Chhabra6
Mega Sage
Mega Sage

Hi @KARAN24 

 

As @Michael Fry1  mentioned, you can leverage decision builders here.

 

Step 1 : Navigate to 'Decision Builder' under 'Decision Management' application 

KaranChhabra6_0-1683223916235.png

 

Step 2: Create a new decision table, I've named it as 'Approver Decision'

             Inputs : Label: Country   Type: String 

In the decision table condition,create two columns one for country (string) and other for group (reference) and enter the approver group against it's respective country & save it

KaranChhabra6_1-1683224098198.png

 

Step 3 : Add a new flow logic named 'Make a decision' to your flow and select the decision which you just created

KaranChhabra6_2-1683224375309.png

In decision table inputs, toggle the script and use this script:

KaranChhabra6_3-1683224496444.png

 

var userGR = new GlideRecord('sys_user');
user.addQuery("sys_id", gs.getUserID());
user.setLimit(1)
user.query();
if (userGR.next()) {
  return userGR.country;
}

 

Step 4 : Add a 'Ask for approval' after this:

KaranChhabra6_4-1683224632448.png

In the approver field use the result record data pill

KaranChhabra6_5-1683224917195.png

 

Since you have decoupled the approver logic using decision builder, you can now add multiple countries and their respective approver there itself.

 

If my answer has helped with your question, please mark it as correct and hepful

 

Thanks,
Karan

Hi Karan,

I tried the above thing,but the issue is ,the flow is skipping the approval

Tried the same in Ask for approval as shown above,but it is coming as approval status as Skipped.

 

Thanks,

Karan