web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Setting the default co...
Power Automate
Unanswered

Setting the default column value of a subfolder in a document library using Power Automate

(0) ShareShare
ReportReport
Posted on by

I have a Flow that automatically creates project folders in a document library on SharePoint based on a form response and I need different folders to have different default column values to make use of searching using metadata. The Folder structure is Client/Location/Project so I want the folders in the client folder to have a default value of the client, the location to have default values of client & location and I want the project folder to have default of the previous as well as the project number.

 

The issue i'm having is that I can set the default column value for the library but I run into issues when I try to set the default values of the subfolders. The error i'm receiving is "List 'xxxxxxxxxx/xx xxxxxx' does not exist at site with URL 'https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'.
clientRequestId: c2e9facc-fe0d-4caf-a611-25f2c6fe21b8
serviceRequestId: 28bfa59f-5061-b000-a4fc-4d19b87acc90"

 

See screenshot below of configuration:

 

bthomas_1-1611850380201.png

 

Any help would be appreciated!

 

Thanks,

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,194 Most Valuable Professional on at

    Hi @Anonymous,

     

    For me it's not entirely clear if you want to update the default value of a column or if you just want to update the metadata of a list item, in this case a folder.

     

    So, I have created REST API examples for both scenarios. Hope this helps a bit?

     

    1. Update the default value of a document library field. In this case I am setting the default value of the field to Contoso Sports.

     

    URI

     

    _api/web/lists/GetByTitle('@{variables('LibraryName')}')/Fields/getbytitle('@{variables('FieldName')}')

     

    Headers

     

    {
     "Accept": "application/json;odata=verbose",
     "Content-Type": "application/json;odata=verbose",
     "X-HTTP-Method": "MERGE",
     "IF-MATCH": "*"
    }

     

    Body

     

    {
     "__metadata": {
     "type": "SP.Field"
     },
     "DefaultValue": "Contoso Sports"
    }

     

    updatedefaultvalue_field.png

     

    2. Update the value of that same field for an item in the document library. In this example I am first retrieving the ListItemEntityTypeFullName. I am using that value for the type in the second request. In this case I am setting the value of the field of the folder item to Contoso.

     

    URI

     

    _api/web/lists/GetByTitle('@{variables('LibraryName')}')?$select=ListItemEntityTypeFullName

     

    Headers

     

    {
     "Accept": "application/json;odata=nometadata"
    }

     

    listentitytypename.png

     

    URI

     

    _api/web/lists/getByTitle('@{variables('LibraryName')}')/items(1)

     

    Headers

     

    {
     "content-type": "application/json; odata=verbose",
     "accept": "application/json; odata=verbose",
     "IF-MATCH": "*",
     "X-HTTP-METHOD": "MERGE"
    }

     

    Body

     

    {
    	"__metadata": {
     "type": "@{outputs('Send_an_HTTP_request_to_SharePoint_-_ListItemEntity')?['body/ListItemEntityTypeFullName']}"
     },
     "@{variables('FieldName')}": "Contoso"
    }

     

     

    updatefolderitemvalue.png

  • Community Power Platform Member Profile Picture
    on at

    Thank you for your detailed reply, for the 2nd one I get an error saying "Invalid JSON. A comma character ',' was expected in scope 'Object'. Every two elements in an array and properties of an object must be separated by commas."

     

    bthomas_0-1611914080163.png

     

    However, the main issue I have and need resolving is setting a default value in a column specifically for the project name subfolder e.g. Contoso/ProjectName

     

    Thanks,

  • Community Power Platform Member Profile Picture
    on at

    I think I have the same need as the original poster - who did not seem to have gotten his issue resolved.

     

    We are trying to use Power Automate to set the default column value at the folder level. Ie. corresponding to the following UI in Sharepoint - Not the general default value for the column in the document library.

    MortenNB_0-1626163866003.png

     

    Any ideas on how to achieve this?

  • sobenson Profile Picture
    169 on at

    Hi @Anonymous did you ever get this working.  I am trying to do the same thing

  • Community Power Platform Member Profile Picture
    on at

    I'm assuming this was never resolved? 

     

    Is there a restapi that allows us to set this setting?

  • Rhiassuring Profile Picture
    8,690 Moderator on at

    There are a few open threads around this request and I figured it out today so thought I'd drop what I figured...

     

    And, a warning:


    🔥TWO LIBRARIES DIED IN THE MAKING OF THIS POST 🔥 


    Don't try this on a Prod library! Test it out and get it working first. (Luckily I wasn't as stupid as I normally am and only tried in test sites.)

    First, my goal was to set default values on sub-folders. 

    Here is my Flow:

    Rhiassuring_0-1659565785010.png

     

    One caveat - this won't work until you've modified one default, as this seems to create the file in the background. (For myself, I have one piece of Library metadata that will default across the board, so I am going to see if I can just set that through API on its own - but wanted to post this first. UPDATE: Updating one default didn't work to trigger the HTML creation. Oh well.) 

    Step 1)
    Initialize a string variable.

    Step 2)
    Get the client_LocationBasedDefaults.html content.

    Rhiassuring_1-1659565866808.png

    Step 3) I have a Compose for step 3, but that's just because it kept failing based on everything I was reading, so I wanted to look at what the DEFAULT output was from this file. If you want to see, you will do this in a Compose:  

     

    decodeBase64(body('Send_an_HTTP_request_to_SharePoint_-_Get_Defaults_String')?['$content'])

    Step 4) Build your defaults! It's not even difficult it's just SO PICKY. Here I am setting values for 2 different folders.

    Rhiassuring_2-1659565944057.png

     

     

     

     <MetadataDefaults><a href="/sites/Intranet/TestDefaults/Test1"><DefaultValue FieldName="TextTest">bad</DefaultValue></a><a href="/sites/Intranet/TestDefaults/Test2"><DefaultValue FieldName="TextTest">good</DefaultValue></a></MetadataDefaults> 

     

     

     

    Step 5) Cram it back into the file and rejoice.

    Rhiassuring_3-1659565986952.png

    Here's what it looks like, with some more complex sends... showing that it inherits properly.

    Rhiassuring_0-1659568308441.png

    I've never been so happy to see those horrible little green gears. Flowers? They kind of look like ICQ flowers.

    PS: This works with MMD as well but you need to structure it as -1;#LABEL|LABELGUID

     

  • jfalgoutIncworx Profile Picture
    2 on at

    Thank you so much for this! I did get it to work by testing what you provided above. However, when I'm trying to do multiples of the same folder on different site columns, it completes, but only changes the first one. Any idea of my error?

    <MetadataDefaults>
    <a href="/sites/Projects/TestDefaults/Test1"><DefaultValue FieldName="State">TX</DefaultValue></a>
    <a href="/sites/Projects/TestDefaults/Test1"><DefaultValue FieldName="Vesper Dept">Projects</DefaultValue></a>
    <a href="/sites/Projects/TestDefaults/Test2"><DefaultValue FieldName="State">CA</DefaultValue></a>
    <a href="/sites/Projects/TestDefaults/Test2"><DefaultValue FieldName="Vesper Dept">Projects</DefaultValue></a>
    </MetadataDefaults>

  • GeorgeNL Profile Picture
    2 on at

    Thank you for you blogpost.

    In my flow, a new folder is created and then I want to set the default values for the columns.
    I can run the flow successfully and the default values are set on the newly created folder, however, the the default values of the previously created folders are deleted.
    In my case the file "client_LocationBasedDefaults.html" is overwritten, so that only the folder created in the flow has a default value.

    How do I make sure the new value is added in to the current client_LocationBasedDefaults.html file instead of creating a new client_LocationBasedDefaults.html every time.

  • Rhiassuring Profile Picture
    8,690 Moderator on at

    You can just create a condition to query for that file - if it finds it, then, just copy the text out and append your updates. If it doesn't, then, create a new one.

  • BasZ Profile Picture
    2 on at

    Thanks for this post but i have given it many tries doing exactly as you do but i am unable to get this working in anyway. I am able to get this working in powershell PNP (i am at the point to just build a function app for this).

    It is a crucial function to have so is there perhaps more information you can give or test if this still works as expected

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard