Invoke a Flow from another (SharePoint) Flow : the HTTP action (step 1/2 Tutorial)

The number of actions in a Microsoft Flow is limited to 250. One way to bypass this is to split your Flow in reusable Flows that can accept parameters : that what I’m going to illustrate in this post.

Here is the scenario : I will create a very basic Microsoft Flow that is supposed to be invoked via a RESTFull/JSon interface.

The expected parameters will be the e-mail address, the e-mail subject and an e-mail body.

The “Calling Flow” will read the information from a SharePoint List and will pass these information to the “Called Flow“.

Let’s create a very basic Modern SharePoint List with 3 columns:

  • emailaddress
  • emailsubject
  • emailbody

sharepointlist

Let’s create a Flow that will be triggered when a new item is created in the list.

callingflow1

A list of templates will show-up. Click on “see more templates” and select “Create a Flow from Blank”. Name the workflow “Calling workflow” and select “SharePoint “as the trigger (see next picture).

callingflow1

Select “when a new item is created” then fill in the site url and select the associated list name. You will be asked to provide your Office 365 account credentials to create a connection object.

Next and just to make sure everything works well add an Office 365 Send an e-mail action

 

callingflow3

Now click on the “Create Flow” button and on “Done”.

Add an item in the SharePoint list and wait for the e-mail to be sent. It can takes between 1 and 15 minutes depending on your Flow subscription (Plan). More details here.

You can also check your Flow history right here (in the Flow portal) (I know we should be able to see that in the SharePoint list directly).

callingflow4

Now let’s focus on creating the called flow.

Create a new Flow from scratch, and name it “Called Flow”. The trigger action should be Request/Response (type “request” in the search box to find it) :

callingflow5

A request action will be added; it expects a JSON definition : copy and paste the following one :

 

{
“$schema”: “http://json-schema.org/draft-04/schema#”,
“type”: “object”,
“properties”: {
“emailaddress”: {
“type”: “string”
},
“emailSubject”: {
“type”: “string”
},
“emailBody”: {
“type”: “string”
}
},
“required”: [
“emailaddress”,
“emailSubject”,
“emailBody”
]
}

Here again add an action to send an e-mail based on the parameters provided to the workflow :

callingflow6

It is also recommended to send an ok message (http 200) back: so after the Send an email action add a Response action

callingflow7

The flow looks like this :

callingflow8

Save your Flow.

If you edit the flow again and click on the Request action, you will see the generated url in Azure : this is the endpoint to any caller (like the Calling Workflow) will have to target.Copy the url in your clipboard.

callingflow9

We need to test the flow and the Postman application is your friend ; install the (free) Postman Chrome app .

In Postman, create a new collection :

callingflow10

in my case I will name it FlowCallFlow:

callingflow11

 

Create a request in this collection (we will reuse it in the next blog post) :

Change the verb Get to POST, set the Body to raw and add the following body :

{
“emailaddress”:”sergeluca@contoso.com”,
“emailSubject”: “Test Flow call Flow”,
“emailBody”: “Hello from Postman”
}

callingflow12

Also set the Header to the value key Content-type  application/json    :

callingflow13

When you click on the Send button, you should get the 200 status code :

callingflow14

This obviously means that the Called workflow has successfully been invoked.Check the sent e-mail.

In Postman save your request in the collection FlowCallFlow.

How can the calling workflow invoke to called workflow ?

The first solution is to use the HTTP action. I will illustrate the second option in my next blog post (Drum Roll suspense 🙂 )

callingflow15

set its properties as following:

callingflow16

You can also remove the Send an email action, we don’t need it anymore.

Save your workflow and and a new item in the SharePoint list.

callingflow17

 

The called workflow will be invoked, will get the values and will send them via e-mail :

callingflow18

You can off course check the Called workflow history, including the associated values.

In the next post I will show you how to proceed differently.

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s