Use Microsoft Flow to Conditionally Create a Contact from a SharePoint List (Part I)

In the previous blog entry, I created a simple Flow to create a CRM Contact from a SharePoint List. In this tutorial, I’ll add a condition to prevent duplicate Contacts based on the email address. This tutorial assumes you have a working Flow between SharePoint online and Dynamics 365 (online).

  1. Access My Flows and open the Flow between SharePoint online and Dynamics 365 labeled, “When an item is create -> Create a new record
  2. Edit the flow and click on the plus sign in between the SharePoint trigger and the Dynamics 365 action.  In the menu, click on Add an action.
  3. Search for Dynamics 365 and select the action, Dynamics 365 – List records

  4. In the new Action, fill in the Organization Name and select Contacts in the Entity Name field.  Click on the Show advanced options link.
  5. With the advanced options expanded, first enter, emailaddress eq ‘’ (two single quotes) in the Filter Query field.
  6. Add an expression in between the two single quotes.  Click once on the Filter Query field and in the pop-up menu, click on Expression and under the String functions, select the toLower(text) expression.
  7. Click once in the Expression field within the parenthesis and then click on Dynamic content.
  8. In the list of Dynamic content, select the Email Address field.  The Expression should update the value to read, toLower(triggerBody()?[‘Title’])   Don’t forget to click on the OK button.
  9. The Filter Query field should look like this and the List records action should return an array of objects where the CRM Contacts Email Address is equal to the Email field in the SharePoint list.
  10. Click on the plus sign in between the List records and Create a new record actions.  In the menu, select Add a condition

  11. In the new Condition, click on Expression and add the value, empty(body(‘List_records’)?[‘value’])  and click on the OK button.
  12. In Condition, click on the value field and click on Expression.  Add the value, true and click on the OK button.
  13. The Condition should look like this:
    (Basic mode)

    (Advanced mode)
  14. Before adding actions to the Condition result, delete the original Create a new record action.
  15. Under the Yes result.  Click on Add an action button.
  16. Search for Dynamics 365 and select the Create a new record action.
  17. Fill in the Dynamics 365 fields. Be sure to choose the SharePoint online field values.
  18. Now click on the Update flow button at the top of the page.
  19. Go to the SharePoint list and create new Contact.  Try to create a duplicate Contact using the same email address.
  20. Once saved go back to Flow and open the Flow to see the Run History.  Click on the top record.
  21. In the flow results details, the Condition Expression result should return false

Leave a Reply

Please log in using one of these methods to post your comment: Logo

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

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.