Create a Workflow with Microsoft Flow

In this demo I will show you, how to create a workflow with Microsoft Flow. I will use a business scenario where the employee apply for a leave in SharePoint List named “Team Calendar” and I as a project lead will get an email to approve or reject the request and based on my response list item will be updated with “Approve/Reject” option in ‘Status’ column.

So let’s get started –

  • First create a sample list “Team Calendar” with 5 columns (Employee Name (Renamed title), Start Date, End Date, Comment Box and Status).
  • Go to the list and click on ‘ Flow’ and then select ‘Create a Flow’.
  • Select the template “Send approval email when a new item is added”. Here Outlook will perform the action of sending an e-mail to the ME (as a Project Lead) and SharePoint will perform the action of updating the “Team Calendar” list. Click ‘Continue’ to proceed.
  • As this flow was created from SharePoint, the ‘Site url’ and ‘list name’ are filled out automatically.
  • Set the information of the user who will get a message when a leave request is submitted to a list. I will set my email address under the field ‘To’.
  • Change the ‘Approval request’ text in the ‘Subject’ field to ‘A new leave request has been submitted by’ and append the ‘Title’ (to have the Employee name in the email subject field).
  • Insert “Approve, Reject” under ‘User options’, so that any of them can be selected directly in the notification email.
  • Delete the condition, as there will be no condition for the email sending.
  • Select ‘New step’ and then ‘New action’ to select the action which will update the SharePoint item.
  • Since we are going to write back the approval decision to the SharePoint item, select the SharePoint action ‘SharePoint – Update item’.
  • Select the site URL in the field ‘Site Url’ and the “Team Calendar” list under the field ‘List name’
  • Select the field ‘ID’ from the dynamic content pop-up box as ‘Id’. This will be the ID from the initial trigger.
  • Select the field ‘Title’ from the dynamic content pop-up box ‘Title’.
  • In the ‘Status’ field, select ‘SelectedOption’ from the dynamic content box. This will be my response (as Project Lead) when I have selected the option.
  • Click on ‘Create Flow’.
  • Click on ‘Done’ to finalize the flow.

To test the flow, add an item in the ‘Team Calendar’ list and make sure an email is sent. Select an option in the email and make sure that the list item status column is updated.

Happy Learning!!

Working with Web Services in SharePoint Designer 2013 Workflow

In this post I will use “Call HTTP web service” action to get a collection of items from a list, and then will log the number of items with it’s title. 
Following is the sample SharePoint List “Call HTTP Webservice Online” I created for this Demo –

Now let’s create a Site workflow as I don’t need this workflow to be fired when items are created or modified in the list

I split this post into 4 different workflow stages: Initialization, Webservice Call, Webservice Response and Finished.

Stage 1: Initialization: 

The following variables get initialized at this stage:

  1. WebserviceURL workflow variable of type ‘string’
  2. Index workflow variable of type Integer & set it to 0. 
  3. Add a Dictionary variable (Build a Dictionary action), call it requestHeaders and initialize it with “Accept” and “Content-Type” entries are of the String type and they both contain the value “application/json;odata=verbose”.

Stage 2: Webservice Call

  1. Add a Call as HTTP Web Service action and set its properties.
  2. Set workflow variable “WebserviceURL” as Web Service URL and Set HTTP method as “GET“.
  3. Response content will go to a new variable called responseContent.(type – Dictionary).
  4. Response headers will go to a new variable called responseHeaders.(type – Dictionary).
  5. Response code will go to a new variable called responseCode.(type – Dictionary ).

Then we set the request headers to be the requestHeaders variable we created just now, by clicking on the properties for the Call on HTTP Web Service action:

Stage 3: Webservice Response

  1. Add a Get an Item from a Dictionary action, set the item as d/results, the source variable reponseContent and the output to a new variable of type Dictionary called List.
  2. Then count items from this list variable using a Count Items in Dictionary action and store the result in a new Integer variable called TotalListItem. This variable will tell us how many times we have to loop.
  3. Now, create a new Integer variable called index and set it to 0 (Set Workflow Variable), this will be the loop index
  4. Add a loop (Loop n Times), and set the loop variable to TotalListItem variable.
  • Inside the loop, get value d/results ([%Variable: index %]) using a Get an Item from a Dictionary action from responseContent and store it in a new Dictionary variable called CurrentItem.
  • Get some fields (Get an Item from a Dictionary) from the CurrentItem variable, such as Title and store them in appropriate variables and then perform any action, like logging its value
  • It’s time to increment the loop counter: add a Do Calculation action and in it increment the index variable into a new Integer variable called IncrementCounter.
  • Then set the index variable to be the IncrementCounter(Set Workflow Variable).

Stage 4: Finished

  1. Finally exit the loop and set the workflow status to Finished.
  2. At the end of the stage, select go to End of Workflow.

Let’s run the workflow –

  1. Go to site content
  2. Click Site Workflow
  3. Select Appropriate workflow
  4. Click it
  5. Workflow started.

Result –

I hope you find this post helpful 🙂

Overview of Microsoft Graph API

While working with Office 365, you might have come across this term so in this post I will describe what is “Microsoft Graph API “, In the simplest words Microsoft Graph is the easiest way to call the Microsoft APIs be it Users, Groups, Mail, Calendars, Contacts, Files etc. all from a single endpoint.

This was previously known as the Office 365 Unified API. It exposes multiple APIs from Microsoft Cloud Services through a single REST API endpoint (https://graph.microsoft.com ).

Prior to Microsoft Graph API, Microsoft had different APIs for it’s different Office 365 and cloud products which needs below steps while dealing with different Office 365 APIs in an application:

  • Find the endpoint of the API
  • Get the access token
  • Get results from the API
  • Repeat for each service
  • Manage multiple tokens for each API

So now understand if one had to connect to many different APIs in an application, it gets difficult to deal with it hence as a solution, Microsoft launched the Microsoft Graph API. Using Microsoft Graph, you just have to make a single endpoint call to the cloud services and require a single authentication token.

Microsoft Graph is a really powerful and easy way to call the Microsoft APIs and all from a single endpoint.

Visit  Microsoft Graph Home  &  Graph explorer to get more information about it.

Thanks!!!