I have had a look at similar topics and tried some of the suggestions but have not found a solution to the following problem -
I am trying to set up a flow which takes variables from PowerApps to send them to SharePoint list to filter the results so I can create a csv file in the flow, but I keep getting an error about the substring length, and can not remove the final 'and' from the compose stage.
The compose code is -
concat(if(not(equals(variables('Room: Site'),'-')), concat('Room: Site eq ''', variables('Room: Site') ,''' and '),''),
if(not(equals(variables('Room: Building'),'-')), concat('Room: Building eq ''', variables('Room: Building') ,''' and '),''),
if(not(equals(variables('Room'),'-')), concat('Room eq ''', variables('Room') ,''' and '),''),
if(not(equals(variables('Equipment'),'-')), concat('Equipment eq ''', variables('Equipment') ,''''),'')
This returns an output with an 'and' on the end. So I have the following to try and remove the 'and' if it's there
if(endsWith(outputs('Compose'),' And '), substring(outputs('Compose'),sub(length(outputs('Compose')),5), length(outputs('Compose'))), outputs('Compose'))
However this doesn't seem to work, as I get the error that my substring can not be as long as my string.
Any help or advise welcome