Automatically Rename Files in Sharepoint from lookup column

Copper Contributor

Hi,

I have a flow to change a files name automatically, based on the column data. Which was working perfectly when all the columns were text inputs or choices.

I then decided to change the Vendor column to a lookup column from a list in sharepoint, called Vendor List. Now the flow no longer works. I think this is because the Vendor name is now a hyperlink which directs you to the list.

How can I get this flow to work?

dj1996_0-1683508748714.png

 

 

3 Replies

hi @dj1996 

it might depend which information from the lookup list is returned.
You should see three potential options within your Cloud Flow for the Vendor column.

The ID, the value and the 'complete field'. 

Micca0815_0-1683535815538.png


In case the value you see here (respectively within the SharePoint library) fits the vendor name already, you can refer to it for your file name.
Otherwise you might think about getting all potential vendors first and filter those based on the ID of your lookup, which is the list item ID of the lookup lists entry.

The following is what you get in return from a lookup column.
The ID is the record ID of the SharePoint list you perform the lookup against.
The value is the column within the lookup list you get the value from (e.g. Title).

    "lookupColumn": {
        "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
        "Id": 1,
        "Value": "demo"
    





Hi @Micca0815 

Thanks for your response. Unfortunately, selecting the 'value' field creates another 'apply to each' function within the current 'apply to each' function, within another 'apply to each' function.

dj1996_0-1684391911297.png


Which then gives me this error:

dj1996_1-1684391961365.png

 

The first apply to each should be done for all items you get in return with your get file (properties only) action.
For the body of the HTTP action you could reference the vendor value for the current item of your get files (properties only) action as follows:
- HTTP body somehow with the following pattern:
.... 'FileLeafRef': items('Apply_to_each')?['VendorColumn']?['VendorColumnValue'] ....