cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jayant_2203
Helper II
Helper II

Check if a Column Exists in Document Library

Hi All,

I have a use case where in i would want to check dynamically in a document library if a column exists in that particular library and if not create that particular column.

is that possible through power automate?

Any help would be appreciated.

1 REPLY 1
Expiscornovus
Dual Super User
Dual Super User

Hi @Jayant_2203,

 

Yes, that would be possible. You could retrieve the existing columns via an Send an HTTP action and the Fields method in the REST API and use a filter array to check if your custom column already exists.

 

Below is an example of that approach.

 

1. Send an HTTP request uses this URI. In this example I am using a string variable ListName which is storing the name of the list.

_api/web/lists/getbytitle('@{variables('ListName')}')/Fields

 

2. Filter Array uses the results collection of the output body.

outputs('Send_an_HTTP_request_to_SharePoint')['body']['d']['results']

 

In the where I am comparing the InternalName of the field to the name of our custom field. In my example that name is stored in a string variable called FieldName.

item()['InternalName']

 

sendanhttprequest_filterarray.png

 

When the output of the Filter Array is empty you could create the new column.

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power automate tips 768x460 v2.png

Restore a Deleted Flow

Did you know that you could restore a deleted flow? Check out this helpful article.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

Users online (2,074)