trigger flow from business rule

jean-pauldehaas
Tera Guru

Hi All,

 

i have a flow for decomissioning a pc, the flow should kick off if an update is done from AD on the computer table.

when the computer gets disabled in AD and this information gets updated in servicenow, the flow should kick of and created the requested item that is attached to the flow.

users are also able to manually create the request but when the request is created automatically the approval in the flow should be skipped.

im not sure how to start is there anyone who can hellp me on the way

1 ACCEPTED SOLUTION

@jean-pauldehaas 

I don't think you can pass any other input to flow

You can do this

1) create a hidden variable on your catalog item and set it via onLoad with some value and hide that variable always

2) then check that variable value in your flow

3) if it has value then it means it is submitted via manual request

4) when flow triggers via BR this variable will be empty

This will help you to skip approval

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

14 REPLIES 14

@jean-pauldehaas 

ensure for this variable Visible on summaries checkbox is unchecked.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar thanks!

i do have a followup question.

the BR is running on the cmdb_ci_computer table because i need to look at a field on the computer form if that gets updated from AD it needs to run the BR and create the catalog item.

i need to set the requested for via that BR and some other field, how can i do that ?

@jean-pauldehaas 

since you can't pass input to flow it would be difficult to know which computer record initiated the flow?

Set unique session variable and get that in flow variable and set the requested for

Something like this

How to use session variable in service now 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Guido Bernuetz
Giga Guru

My suggestion to go:

  1. Create a subflow which contains the actions and tasks
  2. Create a main flow to attach it to a catalog item. In the main flow you can call the subflow and set a parameter which shows the manual start.
  3. Call your subflow also from a business rule (or any other helpful script like scripted webservice) and set the parameter to show the automated start
  4. In the subflow test the parameter value and skip the approval task for example.

I hope that helps!

I am not a helpful hunter.
I will always try to give a meaningful and valid answer.

Ashish Parab
Mega Sage

Hello @jean-pauldehaas ,

 

You can try as below:

Open your flow and click Create code snippet.

AshishParab_0-1736167955539.png

 

Use the server side code inside that function as like below

AshishParab_1-1736168060324.png

 

Uncomment the yellow highlighted line and comment the red highlighted line as you are dealing with background. 

AshishParab_2-1736168235572.png

 

You can use this code directly in your business rule, and the flow will trigger.

 

Please mark this as "correct" and "helpful" if you feel this answer helped you in anyway.

 

Thanks and Regards,

Ashish