In this Power Automate tutorial, we will see, how to check if a field exists in Power Automate. I will show you an example of how to check a field exists in a SharePoint list or document library using Power Automate.
Scenario:
The flow triggers manually and requests the user for the Field name. Then, we will get all the field names from the SharePoint list using the Power Automate HTTP request. Later we will use the filter array action to check if the field exists in the list, and finally, we will send an email.
Follow the below steps to achieve this:
Power Automate Check if the field exists
Let us see how to check if the field exists using Power Automate flow,
In this example, we will use the below Employee SharePoint List consisting of the different fields, and the EmployeeID column is the default title column. so the internal column name will be Title.
Step-1:
Log in to Power Automate, select an Instant Cloud Flow, Expand the Manually trigger action and add an Text input.
Step-2:
Now add a new step and select Send an HTTP request to SharePoint action to get the fields from the SharePoint list. Then provide the SharePoint site address.
- Method- GET
- Uri-_api/web/lists/getbytitle(‘EmployeeList’)/Fields
- Headers-
- Accept – application/json;odata=verbose
- content-type – application/json;odata=verbose
Step-3:
- Select +New step and choose Parse JSON action from the action triggers, and pass the dynamic content value of the Body of the send an HTTP request to SharePoint list action.
body('Send_an_HTTP_request_to_SharePoint')
- In the Schema, pass the sample JSON object value and choose done. It will automatically generate the JSON schema as below:
Step-4:
Add a new step, and select filter array action from action triggers. In the form, the action passes the below expression.
outputs('Send_an_HTTP_request_to_SharePoint')['body']['d']['results']
Pass the below expression to check if the Internal Name is equal to the Folder Name requested by a user.
item()['InternalName']
triggerBody()['text']
Step-5:
Add a compose action and check the length of the filter array. Pass the below expression as an input value.
length(body('Filter_array'))
Step-6:
- Select + new step and Add a condition control to check if the output value is less than or equal to 0. If yes, we will email that the requested field name is available; otherwise, we will email the user that the requested field name already exists.
- If yes, add and send an email action. Then in the To field, select the user email and Provide the Subject and body of the email.
- If No, add and send an email action. Then in the To field, select the user email and Provide the Subject and body of the email.
Step-7:
Save and Run the flow by selecting the Run flow option.
Case 1:
Here we will pass the existing field name called EmployeeDesignation and select the run flow option.
You can see our flow ran successfully like below:
We receive an email to enter a different field name because the field already exists.
Case 2:
Here we will pass the New field name EmployeeReportsTo and select the run flow option.
You can see our flow ran successfully like below:
We receive an email that the requested field is available.
This is how to check if a field exists using Power Automate flow.
In this Power Automate tutorial, we saw how to check if the field exists in the Online SharePoint list using Power Automate flow.
You may also like:
- Power Automate Filter Query If Blank
- Power Automate Skip Function
- Convert CSV to Excel using Power Automate
- How to count rows in a SharePoint list using 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.