Some example uses and tips and tricks
Rename a Folder
You will need to know the following info:
- Site Address
- SharePoint Document List Name
- Folder Location
- Metadata Type (SP.Data.DocumentListNameItem)
Metadata type is the only one that is somewhat tricky to get but once you understand the format it is not too bad. Here is an example on how to get the above info needed:
The SharePoint document location I want to focus on is located here https://testsite.sharepoint.com/sales/Customers AND the folder I want to rename is United States/WA/Ellensburg
- site address is https://testsite.sharepoint.com/sales
- Document List Name is Customers
- Folder location is United States/WA/Ellensburg
- Metadata Type is SP.Data.CustomersItem
- If your Document list name has a space then for example it would be SP.Data.Shared_x0020_DocumentsItem
- If you list has a special character then go here to find a way to get the proper name to use above
If you like you can test a get action to see what is happening
(The below pic is from a production system and showcases using dynamic content)
If you want you can do a compose action to view the type using the following expression:
outputs('Send_an_HTTP_request_to_SharePoint_2')?['body/d/__metadata/type']
Now we move on to renaming the folder
- Select your site address
- Method
- POST
- URI:
_api/web/GetFolderByServerRelativeUrl('Customers/United States/WA/Ellensburg')//ListItemAllFields
- Headers:
{
"Accept": "application/json;odata=verbose",
"X-HTTP-Method": "MERGE",
"If-Match": "*",
"Content-Type": "application/json;odata=verbose"
}
- Body:
{
"__metadata": {
"type": "SP.Data.CustomersItem"
},
"Title": "New Folder Name",
"FileLeafRef": "New Folder Name"
}
Reference:
https://sharepains.com/2020/11/03/rename-sharepoint-folder-power-automate/
How to Get Planner Bucket Name
Update a Person or Group Column Field
How to Get ID of a person on a people picker field
Enter the information on the HTTP action like so
From that output we will see something like this in the body:
You could do a Parse JSON action however I will skip that and use the following expression to select the Id because that is the only JSON I need from this raw output
@{body(‘Send_an_HTTP_request_to_SharePoint_2’)[‘d’]?[‘Id’]}
To create this all I am doing is selecting the Body dynamic content from the HTTP action.
Copy that and paste it into notepad and it looked like this
@{body(‘Send_an_HTTP_request_to_SharePoint_2’)}
I wanted the value in the Id area of the picture above and to get there I need to specify [‘d’] first because that is the top level
Then I added ?[‘Id’] to specify I want to select that data
After that I have this
[‘d’]?[‘Id’]
Finally I add that information to the end of the body request
@{body(‘Send_an_HTTP_request_to_SharePoint_2’)[‘d’]?[‘Id’]}
How to Update Text of a Hyperlink Field in SharePoint
Set a Single Choice Column Value
For this to work properly you need to add the word Value after the column name.
Lets say I have a column called Document Type. If I go to classic view and click the column and look in the browser I can see the true name of the column which for me is DocumentType. Now lets say the choices are Eggs, Milk, Juice. If I want to set Juice I would do the following:
{
“__metadata”:{
“type”:”Microsoft.SharePoint.DataService.SharePointListNameItem”
},
“DocumentTypeValue”: “Juice”
}