Use Equals Expression For Simple Data Transformations
  • Updated on 22 Sep 2019
  • 1 minute to read
  • Contributors
  • Print
  • Comments
  • Share
  • Dark
    Light

Use Equals Expression For Simple Data Transformations

  • Print
  • Comments
  • Share
  • Dark
    Light

#ServerlessTips - Microsoft Flow
Author: Kent Weare Integration MVP

In this tip, we will discuss the equals expression which we can be used to perform simple data transformations by evaluating one value against another. More specifically, the Microsoft documentation describes the equals behavior as: “Checks whether both values, expressions, or objects are equivalent. Return true when both are equivalent or return false when they're not equivalent.”
1-form.png
On the SharePoint side, we have a list defined, that includes Yes/No columns for this data. Calling them Yes/No fields is a bit misleading as you can’t send the list a Yes or No value and certainly not as a String. Instead we need to send a Boolean value.
2-SharePoint.png
This is where our equals expression comes in as it is able to detect if our form value is equal to ‘Yes’ and if it is, it will return a true value that is sent to SharePoint. In the event, it is not equal to ‘Yes’, then a false value will be sent to SharePoint.
We can include equals expressions for each of our Yes/No questions and include them in SharePoint Create Item action. As a result, our expression looks like the following:

equals(body('Get_response_details')?['** Forms Field **'],'Yes')

3-expression.png

Testing

With our configuration set, we can now perform a test. To illustrate both a ‘Yes’ and ‘No’ scenario, we will specify on the form that we are interested in Microsoft Flow and Azure Logic Apps information, but not PowerApps.
When we run our logic app, we will see that our ‘Yes’ values coming from Microsoft Forms are converted to true values before they are inserted into SharePoint. On the flipside, our ‘No’ value from Microsoft Forms is converted to a false value as it is inserted into SharePoint.

test.png

Conclusion

Using the equals expression allows us to detect a specific value and then return a Boolean value that indicates if we have a match. It becomes very useful when translating Strings to Boolean values.

Was this article helpful?