cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gm355
Level: Powered On

Invalid expression when trying to shorten a file name

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'))
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support Team
Community Support Team

Re: Invalid expression when trying to shorten a file name

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.

 

View solution in original post

1 REPLY 1
Highlighted
Community Support Team
Community Support Team

Re: Invalid expression when trying to shorten a file name

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.

 

View solution in original post

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Users online (5,290)