Microsoft Flow: Condition syntax for SharePoint columns

Blog post: 2 minute read

Are you a Power User working with SharePoint in Office 365? Do you plan on using a SharePoint list or library with Microsoft Flow? If so, read on! In this post, I’ll show condition syntax for common SharePoint column types when building a Microsoft Flow. To demonstrate this, I’ll show five frequently used column types and how to use them in a condition – something you’ll find yourself routinely needing to do.

Although this information is available thru other reference material, I wanted all examples in one place for a quick reference.

Check out my other post, Microsoft Flow: Update SharePoint columns, where I demonstrate how to update each of these 5 SharePoint column types in a Microsoft Flow.

Here are the site column names I’ll use and their column types:

ColumnDefinitions

The examples show the advanced mode condition and use the Workflow Definition Language. You can get to the advanced mode by clicking Edit in advanced mode while editing the condition in Microsoft Flow (image). In most cases, you can start in basic mode and the advanced formula is automatically created for you, however its important to understand the syntax being used behind-the-scenes and to assist in troubleshooting.

AdvancedMode

If you need to enter an expression, click Add dynamic content and then Expression to create the expression. (often required when working with dates)

Expression

 


ExampleChoiceColumn condition:

  • Requirement: Check for a choice value of ‘East’:
    • Condition: @equals(triggerBody()?[‘ExampleChoiceColumn’]?[‘Value’], ‘East’)
    • Tip: ensure you are using the Value of the choice column and not just the column name.

ChoiceValue


ExampleDateColumn condition:

Note: The ExampleDateColumn is defined as a Date only column in this example. Ensure all expressions are formatted to the correct date format for your comparisons to work. In these examples, I’m using yyyy-MM-dd. Eg. 2018-02-17

  • Requirement: Check for a date value of Today:
    • Expression formula: formatDateTime(utcNow(), ‘yyyy-MM-dd’)
    • Condition: @equals(triggerBody()?[‘ExampleDateColumn’], formatDateTime(utcNow(), ‘yyyy-MM-dd’))
  • Requirement: Check for a date value prior to 1 week in the past:
    • Expression formula: formatDateTime(addDays(utcNow(), -7), ‘yyyy-MM-dd’)
    • Condition: @lessOrEquals(triggerBody()?[‘ExampleDateColumn’], formatDateTime(addDays(utcNow(), -7), ‘yyyy-MM-dd’))
  • Requirement: Check for a null date value:
    • Advanced condition only: @empty(triggerBody()?[‘ExampleDateColumn’])
    • Note: you cannot enter this in basic mode. This is an example where you must be in advanced mode to enter the formula

ExampleLookupColumn condition:

  • Requirement: Check for a lookup value of ‘North’:
    • Condition: @equals(triggerBody()?[‘ExampleLookupColumn’]?[‘Value’], ‘North’)
    • Tip: ensure you select the value of the lookup column and not the column on its own or the Id.

LookupValue


ExampleManagedMetadataColumn condition:

  • Requirement: Check for a managed metadata term value of ‘North’:
    • Condition: @equals(triggerBody()?[‘ExampleManagedMetadataColumn’]?[‘Label’], ‘North’)
    • Tip: ensure you select the Label and not the Value. The Value is the guid of the term.

MMValue

 


ExampleYesNoColumn condition:

  • Requirement: Check for a value of ‘Yes’:
    • Condition: @equals(triggerBody()?[‘ExampleYesNoColumn’], true)
  • Requirement: Check for a value of ‘No’ (either of these would work):
    • Condition: @not(equals(triggerBody()?[‘ExampleYesNoColumn’], true))
    • Condition: @equals(triggerBody()?[‘ExampleYesNoColumn’], false)

I hope you found this post helpful. 🙂

Thanks for reading.

-JCK


Credit: Photo by Scott Webb on Unsplash

 

7 comments

Leave a Reply

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