web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Rename SharePoint file...
Power Automate
Suggested Answer

Rename SharePoint file based on Sharepoint Library Metadata

(1) ShareShare
ReportReport
Posted on by 44
I've spend two days struggling with this so I hope those here can help.
I have a SharePoint document library with these fields:  
NAME,
TITLE,
Document Create Date (This is not the Creation date)
UNITName (Management Metadata field).
 
I want to create a new file name using CONCAT with YYYYmmDD from the Document Create Date, UNITName, Title, (then file extension).
This is my FLOW:  
First Two step details:
This is my CONCAT component:
 
This is my HTTP portion:  
Categories:
I have the same question (0)
  • Suggested answer
    11manish Profile Picture
    3,333 on at
    try below (Might be helpful)
     
    Use this in Compose or Rename file action:
     
    concat(
        formatDateTime(triggerOutputs()?['body/DocumentCreateDate'], 'yyyyMMdd'),
        '_',
        triggerOutputs()?['body/UNITName']?['Label'],
        '_',
        triggerOutputs()?['body/Title'],
        '.',
        last(split(triggerOutputs()?['body/{FilenameWithExtension}'], '.'))
    )
  • Suggested answer
    Haque Profile Picture
    3,653 on at
     
    What your cmpose expression prodcues or what problems you are facing now? Can you please share/post here?
     

    My two cents with @11manish:

    Is UNITName a Choice field?: You correctly access the .Label property of the choice field. Make sure UNITName is indeed a choice or lookup field with a Label property. Sometimes it might be .Value or just a string depending on your data source.

    Null or missing values - If any of these fields can be empty or null, consider wrapping them with coalesce() to provide defaults and avoid errors. For example:

    coalesce(triggerOutputs()?['body/UNITName']?['Label'], 'UnknownUnit')
    
     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!
  • CU08031624-0 Profile Picture
    44 on at
    So the assistance was great, but I am now presented with a different error: 
    This is identified in my Send an HTTP Request to SharePoint.
    Any followup assistance is appreciated!  Thanks everyone.
  • Suggested answer
    Haque Profile Picture
    3,653 on at
     
     
    Hm...somewhere in your JSON payload or body for the HTTP request, there is a missing comma between properties or array elements. This is a common syntax error in JSON formatting. Please check and fix it. I am giving the clue.
     
     
    If you see the error carefully - it says: Invalid JSON. A comma character ',' was expected in scope 'Object'. Every two elements in an array and properties of an object must be sparated by commas.
     
    Missing commas between key-value pairs in JSON objects: Example of incorrect JSON:
     
    {
      "property1": "value1"
      "property2": "value2"
    }
    
    Correct JSON:
    {
      "property1": "value1",
      "property2": "value2"
    }
    
    Please note the comma "," after the first property value.
     
    Note: JSON does not allow trailing commas after the last element or property. The extra comma after the first property value is invalid and the last comma after the second property value is invalid.
     
    {
      "property1": "value1",,
      "property2": "value2",
    }
    
     
     
  • CU08031624-0 Profile Picture
    44 on at
    SO I have changed my COMPOSE STATEMENT TO THIS:
    And this is my HTTP BODY:
     
    {
    '__metadata': {
    'type':'SP.Data.OutlinesItem'
    },
    'FileLeafRef':'@{outputs('Compose')}'
    }
     
     
    I am still getting the error.
     
    This is just so frustrating.  I'm under a time crunch and Power Automate is making troubleshooting so difficult!
     
  • Haque Profile Picture
    3,653 on at
    Can you please post here Compos's output once run?
  • CU08031624-0 Profile Picture
    44 on at
    This is the OUTPUT from the COMPOSE section after running and failing.
     
    concat(
        formatDateTime(triggerOutputs()?['body/Date_x0020_of_x0020_Document'], 'yyyyMMdd'),
        '_',
        coalesce(triggerOutputs()?['body/UNITName']?['VALUE'],'NA'),
        '_',
        replace(coalesce(triggerOutputs()?['body/Title'],'NoTitle'), '/', '-'),
        '.',
        last(split(triggerOutputs()?['body/{FilenameWithExtension}'], '.'))
    )
     
     
    THIS IS THE RAW OUTPUT:
    ___________________________________________________________
    "concat(\n    formatDateTime(triggerOutputs()?['body/Date_x0020_of_x0020_Document'], 'yyyyMMdd'),\n    '_',\n    coalesce(triggerOutputs()?['body/UNITName']?['VALUE'],'NA'),\n    '_',\n    replace(coalesce(triggerOutputs()?['body/Title'],'NoTitle'), '/', '-'),\n    '.',\n    last(split(triggerOutputs()?['body/{FilenameWithExtension}'], '.'))\n)"
    _________________________________________
     
    Thanks for all of your assistance!
  • Suggested answer
    Kalathiya Profile Picture
    2,456 Super User 2026 Season 1 on at
     
    I think the error is getting due to quotation marks in the JSON body.
     
    Please try below: 
    {
      "__metadata": { "type": "SP.Data.Shared_x0020_DocumentsItem" },  
      "FileLeafRef": "NEW_FILENAME.ext"
    }
    
    Note:  Shared_x0020_DocumentsItem - Please update with your naming conversation. 
     
            
     
     
     
    If this response resolves your issue, please mark it as the Verified Answer so it can help other community members as well.
    ---------------------------------------------------------------------------------

    📩 Need more help? Just mention @Kalathiya and I’ll be happy to assist.

    ✔️ If this answer helped you, please tick “Does this answer your question?” so it can be marked as the Verified Answer.

    💛 A Like always motivates me to keep contributing!​​​​​​​

  • CU08031624-0 Profile Picture
    44 on at
    @Kalathiya
     I have changed the quotes to single quotes - same error.
    Thanks for your response though.
     
    The JSON does require quotes
  • Suggested answer
    Haque Profile Picture
    3,653 on at
     
     

    Can you please check what's the file name it bring here? What I meant is, when you built file name dynamically in the Compose above what it produced? 

     
    {
      "__metadata": { "type": "SP.Data.Shared_x0020_DocumentsItem" },
      "FileLeafRef": "@{outputs('Compose')}"
    }
    
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 377

#2
11manish Profile Picture

11manish 279

#3
David_MA Profile Picture

David_MA 234 Super User 2026 Season 1

Last 30 days Overall leaderboard