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 / Invalid expression whe...
Power Automate
Answered

Invalid expression when trying to shorten a file name

(0) ShareShare
ReportReport
Posted on by 61

I’ve created a variable called FullFileName and I now want to use an expression to say - if the file name is greater than 155 characters, take the first 155, otherwise take the whole name.

 

Getting an error saying the expression is invalid, can anyone spot what I’m doing wrong?

 

if(greaterOrEquals(length(triggerBody()? variables('FullFileName')), 155), substring(triggerBody()? variables('FullFileName'), 0, 155), triggerBody()? variables('FullFileName'))
Categories:
  • Verified answer
    v-alzhan-msft Profile Picture
    Microsoft Employee on at

    Hi @gm355 ,

     

    You could take a try with expression below:

    if(greater(length(variables('FullFileName')),155),substring(variables('FullFileName'),0,155),variables('FullFileName'))

    I have made a test on my side, please refer to screenshot below to create the flow:

    1.png 

     

    The expression in the Compose as below:

    if(greater(length(variables('FullFileName')),5),substring(variables('FullFileName'),0,5),variables('FullFileName'))

     

    The flow would run successfully as below:

    2.png

     

     

    Best regards,

    Alice       

     

    Community Support Team _ Alice Zhang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 414

#2
11manish Profile Picture

11manish 335 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 274

Last 30 days Overall leaderboard