cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

At wits end with Logic App Substring - PLEASE HELP

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
8 REPLIES 8
Highlighted
Super User III
Super User III

Re: At wits end with Logic App Substring - PLEASE HELP

Hello @mikekiser 

 

Have you tried to use the substring action? For complex subscribe expressions, it can be very useful.





Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up ?


Proud to be a Flownaut!





Highlighted
Super User III
Super User III

Re: At wits end with Logic App Substring - PLEASE HELP

@mikekiser  Here is a blog on the substring action:

https://flowaltdelete.ca/2020/07/14/power-automate-substring-and-text-positions-made-easy/





Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up ?


Proud to be a Flownaut!





Highlighted
Helper I
Helper I

Re: At wits end with Logic App Substring - PLEASE HELP

Thanks. I did try the SubString but must have been doing something wrong. I'll read the blog; thanks for your post!
Mike

Highlighted
Helper I
Helper I

Re: At wits end with Logic App Substring - PLEASE HELP

Hi,

I am trying to use this after reading the blog but I am getting a syntax error

 

substring(variables(Address),0,9)
 
 
It looks good to me; any ideas?
Thanks
Mike
Highlighted
Super User III
Super User III

Re: At wits end with Logic App Substring - PLEASE HELP

@mikekiser 

 

Try changing to:

substring(variables(Address),1,9)

 

I dont think substring() uses array indexes.





Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up ?


Proud to be a Flownaut!





Highlighted
Helper I
Helper I

Re: At wits end with Logic App Substring - PLEASE HELP

Thanks for your response but it still failed

 

error:

InvalidTemplate. 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. Please see https://aka.ms/logicexpressions#substring for usage details.'.

 

code:

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

Re: At wits end with Logic App Substring - PLEASE HELP

@mikekiser  In the run of that error. Could you share the parse json2 address1 property value.

 

I want to confirm what is in the address1 property.





Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up ?


Proud to be a Flownaut!





Highlighted
Super User III
Super User III

Re: At wits end with Logic App Substring - PLEASE HELP

Hello @mikekiser 

You are getting this error if the string you're trying to substring is too short.

Try adding a condition to check for this before doing the conversion

Please take a look at my POC:

 

Keep in mind I am using lots of Compose actions to show what is happening. You can use less for your solution

 

First I get the length of address1

Than I use a IF condition to check if address1 is greater than 30 chars

Jcook_0-1596247991095.png

 

If True:

Use the substring() expression on address1 

my expression is:

substring(outputs('Compose_-_address1'),0,30)

Jcook_1-1596248207107.png

 

If False:

Do nothing

 

Run:

with address1= This Address is too short

Jcook_2-1596248386121.png

 

Run:

With address1 = This Address is too long and will be trunked

Jcook_3-1596248480598.png

 





Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up ?


Proud to be a Flownaut!





Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

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!

Users online (8,187)