cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bthomas
Frequent Visitor

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

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,

3 REPLIES 3
Expiscornovus
Super User
Super User

Hi @bthomas,

 

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

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,

MortenNB
New Member

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?

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,678)