Logic App Truncate?? Please help...urgent

Mike Kiser 1,531 Reputation points
2020-07-31T18:31:01.487+00:00

Hi

We have some addresses that are greater than 30 chars and I have to truncate those to 30 chars max.....what I am trying to do is

"Condition_2": {
"actions": {
"Set_variable": {
"inputs": {
"name": "Address",
"value": "@{substring(body('Parse_JSON_2')?['address1'],0,29)}"
},
"runAfter": {},
"type": "SetVariable"
}

The error I am getting is: PLEASE HELP! Thanks Mike Kiser
Unable to process template language expressions in action 'Set_variable' inputs at line '1' and column '2956': 'The template language function 'substring' parameters are out of range: 'start index' and 'length' must be non-negative integers and their sum must be no larger than the length of the string

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,838 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ChaitanyaNaykodi-MSFT 22,386 Reputation points Microsoft Employee
    2020-07-31T23:08:39.357+00:00

    Hello @Mike Kiser ,

    You can utilize the "if" logical comparison function long with the greater ,length and take in the following manner.

    "value": "@if(greater(length('enter_your_value'),30), take('enter_your_value',30), 'enter_your_value')",  
    

    Please let me know if this solution does not solve your issue I will be happy to continue with our discussion.