Substring Left Right Expression

%3CLINGO-SUB%20id%3D%22lingo-sub-1103122%22%20slang%3D%22en-US%22%3ESubstring%20Left%20Right%20Expression%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1103122%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20All%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20built%20an%20expression%20in%20Power%20Automate%20and%20want%20to%20know%20if%20there%20is%20a%20better%20way%20to%20achieve%20the%20same%20result.%20The%20expression%20creates%20a%20work%20order%20number%20that%20concatenates%20a%20prefix%20value%2C%20leading%20zeros%20and%20a%20unique%20number.%20The%20leading%20zeros%20and%20unique%20number%20should%20not%20exceed%205%20characters%20in%20length.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere%20is%20an%20example%20work%20order%20number%3A%20%22ES00099%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20far%20as%20I%20know%20there%20is%20no%20%22Left%22%20or%20%22Right%22%20style%20functions%20in%20Power%20Automate%20to%20simplify%20this%20expression.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20my%20expression%20I%20am%3A%3C%2FP%3E%3COL%3E%3CLI%3EConcatenating%20%2200000%22%20and%20the%20List%20ID%20number%20(%2299%22).%20Results%20in%20%220000099%22.%3C%2FLI%3E%3CLI%3EDetermine%20concatenated%20string%20length%20(7)%3B%20Subtract%20it%20from%20the%20desired%20string%20length%20(5)%20%3D%203.%3C%2FLI%3E%3CLI%3ESubstring%26nbsp%3B%220000099%22%20and%20using%20Step%20%232%20result%20(3)%20and%20desired%20string%20length%20(5).%20Results%20in%20%2200099%22.%3C%2FLI%3E%3CLI%3EConcatenate%20%22AA%22%20to%20Step%20%233%20result.%20Results%20in%20%22ES00099%22.%3C%2FLI%3E%3C%2FOL%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F164894iBF7015CA19102C12%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22clipboard_image_0.png%22%20title%3D%22clipboard_image_0.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere%20is%20the%20full%20expression%20code%3A%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CPRE%3E%3CSPAN%3Econcat(%3C%2FSPAN%3E%3CSPAN%3E'ES'%3C%2FSPAN%3E%3CSPAN%3E%2C%20substring(concat(%3C%2FSPAN%3E%3CSPAN%3E'00000'%3C%2FSPAN%3E%3CSPAN%3E%2C%20triggerBody()%3F%5B%3C%2FSPAN%3E%3CSPAN%3E'ID'%3C%2FSPAN%3E%3CSPAN%3E%5D)%2C%20sub(length(concat(%3C%2FSPAN%3E%3CSPAN%3E'00000'%3C%2FSPAN%3E%3CSPAN%3E%2C%20triggerBody()%3F%5B%3C%2FSPAN%3E%3CSPAN%3E'ID'%3C%2FSPAN%3E%3CSPAN%3E%5D))%2C%205)%2C%205))%3C%2FSPAN%3E%3C%2FPRE%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20code%20works%20but%20I'm%20thinking%20there%20must%20be%20a%20more%20elegant%20way.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENorm%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1103122%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Flow%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
MVP

Hello All,

 

I've built an expression in Power Automate and want to know if there is a better way to achieve the same result. The expression creates a work order number that concatenates a prefix value, leading zeros and a unique number. The leading zeros and unique number should not exceed 5 characters in length.

 

Here is an example work order number: "ES00099"

 

As far as I know there is no "Left" or "Right" style functions in Power Automate to simplify this expression.

 

In my expression I am:

  1. Concatenating "00000" and the List ID number ("99"). Results in "0000099".
  2. Determine concatenated string length (7); Subtract it from the desired string length (5) = 3.
  3. Substring "0000099" and using Step #2 result (3) and desired string length (5). Results in "00099".
  4. Concatenate "AA" to Step #3 result. Results in "ES00099".

clipboard_image_0.png

 

Here is the full expression code:

concat('ES', substring(concat('00000', triggerBody()?['ID']), sub(length(concat('00000', triggerBody()?['ID'])), 5), 5))

 

The code works but I'm thinking there must be a more elegant way.

 

Thanks.

 

Norm

 

0 Replies