How to Check if a field exists in Power Automate?

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.

Power Automate Check if the field exists

Step-1:

Log in to Power Automate, select an Instant Cloud Flow, Expand the Manually trigger action and add an Text input.

Power Automate Check if the field exists or not

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
Check if the field exists or not using Power Automate

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:
Example to Check if the field exists or not using Power Automate

Step-4:

See also  Power bi measure divide + 9 examples

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']
Example to Check if the field exists or not using Power Automate flow

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'))
Check if the field exists or not using Power Automate flow

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.
Power Automate Check if the field exists or not using Microsoft flow

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.

Power Automate Check if the field exists using Microsoft flow

You can see our flow ran successfully like below:

Check if the field exists using Microsoft flow

We receive an email to enter a different field name because the field already exists.

Check if the field exists using the Microsoft flow

Case 2:

Here we will pass the New field name EmployeeReportsTo and select the run flow option.

Check if the field exists using the Power Automate flow

You can see our flow ran successfully like below:

Check if the field exists or not using Microsoft flow

We receive an email that the requested field is available.

Check if the field exists or not using the Microsoft flow

This is how to check if a field exists using Power Automate flow.

See also  Power Automate String Functions + 10 Examples

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:

>