Home > Forum > Actions > Edit a list element in a subfolder

Edit a list element in a subfolder
0

Hi everyone,

I have a SharePoint document library with subfolders. From a WEBCON workflow I upload a file into one of these subfolders using the action “Add an attachment to a list”, and afterwards I want to update the metadata columns of that file using “Edit a list element”. The upload itself works fine: the document is placed correctly in the subfolder. However, when I try to update the metadata of this uploaded document with “Edit a list element”, it does not work.

Does anyone know a trick or workaround to solve this?

Thanks in advance and kind regards,
Mario

MVP

Hi Mario,

I have never used the standard actions and always relied on the SharePoint REST API. :)

If you have the item id of the file you could use this a starting point:

Method: POST
https://{tenant}.sharepoint.com/sites/{site}/_api/web/lists/getbytitle('Documents')/items({itemId})
X-HTTP-Method: MERGE
IF-MATCH: *

Body
{
"Title": "My new title",
"Department": "Finance",
"OwnerId": 12,
"RelatedProjectId": 5
}


If you only have the filename, which is risky, if it get's renamed or the file is moved in SharePoint, you can use this:

Method: POST
https://{tenant}.sharepoint.com/sites/{site}/_api/web/GetFileByServerRelativePath(decodedurl='/sites/{site}/Shared Documents/Folder/SubFolder/file.docx')/ListItemAllFields

Headers:
X-HTTP-Method: MERGE
IF-MATCH: *

Body
{
"Title": "My new title",
"Department": "Finance",
"OwnerId": 12,
"RelatedProjectId": 5
}


The property names are the internal field names.

Best regards,
Daniel