Forum Discussion

dj1996's avatar
dj1996
Copper Contributor
May 08, 2023

Automatically Rename Files in Sharepoint from lookup column

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?

 

 

  • Micca0815's avatar
    Micca0815
    Iron Contributor

    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'. 


    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"
        





    • dj1996's avatar
      dj1996
      Copper Contributor

      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.


      Which then gives me this error:

       

      • Micca0815's avatar
        Micca0815
        Iron Contributor
        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'] ....

Resources