Divyesh Jesadiya
Divyesh Jesadiya

Reputation: 957

Getting "The expression is invalid" in compose of power automate

I was trying to remove last character(comma) from my variable Images in power automate using compose action as below using expression.

if(endsWith(variables('Images'), ','), substring(variables('Images'), 0, length(variables('Images')) - 1), variables('Images'))

But when I click OK button in expression it always saying "The expression is invalid". but I don't know what is the problem there. Below is flow image. enter image description here

Upvotes: 0

Views: 276

Answers (1)

Skin
Skin

Reputation: 11262

Yeah, you can't do something - 1, it's all expression based so you need to use the sub() function.

This will work for you ...

if(endsWith(variables('Images'), ','),
  substring(variables('Images'), 0, sub(length(variables('Images')), 1)),
  variables('Images')
)

Upvotes: 1

Related Questions