Do you want to check whether a string contains a value in Power Automate? This Power Automate tutorial will help you check whether the string contains a value or not using the contains function in Power Automate.
Scenario:
Recently, I got a requirement to check whether the particular field value contains the string using Power Automate. Here, I will use two SharePoint lists called Inquiry List and Trainer List.
Inquiry List consisting of below fields:
Column Name | Column Type |
Name | default title column |
City | Single line of Text column |
ContactNumber | Number column |
Remarks | Multiple lines of text column |
Trainer List consisting of below fields:
Column Name | Column Type |
Technology | default title column |
Trainers | People or Group column |
So, the flow uses an automatic trigger. Whenever a new item is added to the inquiry list, the flow will trigger, and it will check the Remark field contains the string value, if it matches, then it notifies the respective trainer.
- If the remarks field contains the values PowerApps, PowerAutomate, and PowerBI, then it notifies the PowerPlatform Trainer.
- Similarly, if the remarks field contains the value SPFX, it notifies the SPFX trainer.
- Also, if the remarks field contains the value SharePoint, it notifies the SharePoint Trainer.
- Finally, if the remarks field doesn’t contain any of these values (PowerApps, PowerAutomate, PowerBI, SPFX, SharePoint), it notifies the Others Trainer.
Now we will start to create a flow to check conditions containing string using Power Automate:
Check condition contains string using Power Automate
Let us see how to check whether the condition contains the string value or not using the Power Automate.
Step-1:
Create an automated cloud flow with the trigger when an item is created; provide the required parameters:
- Site Address: select the SharePoint site address
- List Name: from the dropdown, select the list name (here, I have selected the Inquiry List)
Step-2:
Add a compose data operation, and from the dynamic content, pass the Remarks field as shown below:
@{triggerOutputs()?['body/Remarks']}
Step-3:
Add a compose data operation and use the below expression to remove all the white spaces from the remarks field value.
replace(outputs('Remarks'),' ','')
Step-4:
Add a compose data operation and check the remarks field in the SharePoint list containing these values PowerApps, PowerAutomate, and PowerBI.
Here I have also used the tolower()function to check if the remarks field contains lowercase values like power apps, power automate, or power bi.
or(contains(outputs('RemoveWhiteSpaces'),'PowerApps'),contains(outputs('RemoveWhiteSpaces'),toLower('PowerApps')),contains(outputs('RemoveWhiteSpaces'),'PowerAutomate'),contains(outputs('RemoveWhiteSpaces'),toLower('PowerAutomate')),contains(outputs('RemoveWhiteSpaces'),'PowerBI'),contains(outputs('RemoveWhiteSpaces'),toLower('PowerBI')))
Add a new step, select compose data operation, and use the below expression to check if the remarks field in the list contains the value SPFX,
contains(outputs('RemoveWhiteSpaces'),'SPFX')
Similarly, add another compose data operation and use the below expression to check whether the remarks field contains the value SharePoint or not.
or(contains(outputs('RemoveWhiteSpaces'),'SharePoint'),contains(outputs('RemoveWhiteSpaces'),toLower('SharePoint')))
Finally, add another compose data operation and use the below expression to check if the remarks field doesn’t contain any of these values (PowerApps, PowerAutomate, PowerBI, SPFX, SharePoint).
and(if(equals(outputs('PowerPlatform'),false), true,false),if(equals(outputs('SPFX'),false),true,false),if(equals(outputs('SharePoint'),false),true,false))
Step-5:
Add a new step, then choose the Get items action and provide the required parameters:
- Site Address: select the SharePoint site address
- List Name: from the dropdown, select the list name (here, I have selected the Trainer List)
Step-6:
Add a condition control and check if the Technology (default title column)is equal to the Power Platform; it will automatically add the apply to each control loop.
If yes, add another condition control and check if the outputs of PowerPlatform compose data operation is equal to true. If no, leave it blank
In the If yes part, add a send an email action(V2) to notify the Power Platform trainer. Provide the required parameter:
- To – From the dynamic content, select Trainers Email
- Subject – Enter the subject of the mail
- Body – Enter the body of the mail
If no, leave it blank.
Inside the loop, Add a new step, select the condition control, and check if the Technology (default title column) is equal to the SPFX,
If yes, add another condition control and check if the outputs of the SPFX compose data operation is equal to true. If no, leave it blank
In the If yes part, add a send an email action(V2) to notify the SPFX trainer. Provide the required parameter:
- To- From the dynamic content, select Trainers Email
- Subject – Enter the subject of the mail
- Body – Enter the body of the mail
If no, leave it blank.
Inside the loop, Add a new step, select the condition control, and check if the Technology (default title column) is equal to the SharePoint,
If yes, add another condition control and check if the outputs of SharePoint compose data operation is equal to true. If no, leave it blank
In the If yes part, add a send an email action(V2) to notify the SharePoint trainer. Provide the required parameter:
- To- From the dynamic content, select Trainers Email
- Subject – Enter the subject of the mail
- Body – Enter the body of the mail
If no, leave it blank.
Add a new step, select the condition control, and check if the Technology (default title column) is equal to Others,
If yes, add another condition control and check if the outputs of the Others compose data operation is equal to true. If no, leave it blank
In the If yes part, add a send an email action(V2) to notify the SharePoint trainer. Provide the required parameter:
- To- From the dynamic content, select Trainer Email
- Subject – Enter the subject of the mail
- Body – Enter the body of the mail
If no, leave it blank.
Step-6:
Our complete flow looks like the below:
Save and run the flow by selecting the run flow option:
Test Case-1
The flow will trigger when a new item is added to the SharePoint inquiry list. Here I have added the highlighted list item below.
The Remarks field contains the value SharePoint.
Once the flow runs successfully, the SharePoint Trainer will receive an email like the one below. For testing purposes, I used my account to create the list item, which is why the created by field shows my display name.
Similarly, it works for the remaining conditions that are presented in the flow:
Test Case-2
Similarly, I have added another item in the SharePoint list; in the Remarks field, we can see it doesn’t contain any of these values (PowerApps, PowerAutomate, PowerBI, SPFX, SharePoint).
So once the flow runs successfully, the Others Trainer will receive an email like the one below:
This is how to check whether the condition contains the string value or not using Power Automate.
Conclusion
So, I hope you get an idea of how to check whether the condition contains the string value or not using the Power Automate Contains function().
I have shown you an example; whenever a new item is added to the inquiry list, the flow will trigger, and it will check whether the Remark field contains the string value if yes, then it notifies the respective trainer.
You may also like the following tutorials:
- Power Automate Copy Files from OneDrive to SharePoint
- How to Get the First Character from a String in Power Automate?
- How to Convert an Array to a String in Power Automate
- How to Remove Quotes from String in Power Automate?
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.