cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

[Solved] - Extract last n-characters from Form input

Hello everyone, 

 

I have a pretty simple requirement but I can't seem to figure out how to achieve this in Flow. 

 

I have a form where a user is requested to input an ID number with or without the leading characters, such as:

 

XYZ000000333222

333222

XYZ333222

XYZ000333222

 

I am only interested in the last 6 characters of their input (333222 in this example) as I can modify the string later in SharePoint when I do a DB lookup. Using a regular expression ((.{6})\s*$) this is very simple but I'm not sure how to achieve this using a substring or split or some other expressions within Flow.

2019-03-27_20-05-27.jpg

 

Regex.jpg

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Resident Rockstar
Resident Rockstar

Re: Extract last n-characters from Form input

Hi @scottgm23 , thank you for your post.

I have simulated your form input by using "Compose Input" below:Capture-423.png

sub(length(outputs('Compose_Input')), 6)
substring(outputs('Compose_Input'), int(outputs('Compose_Number_Of_Characters_In_Input')), 6)

Regardless of what the input is, this method will get you the last 6 digits of the ID number.

 

If you have found my post helpful, please mark thumbs up.

 

Any other questions, just ask.

 

Thanks, Alan


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

Proud to be a Flownaut!


View solution in original post

4 REPLIES 4
Highlighted
Resident Rockstar
Resident Rockstar

Re: Extract last n-characters from Form input

Hi @scottgm23 , thank you for your post.

I have simulated your form input by using "Compose Input" below:Capture-423.png

sub(length(outputs('Compose_Input')), 6)
substring(outputs('Compose_Input'), int(outputs('Compose_Number_Of_Characters_In_Input')), 6)

Regardless of what the input is, this method will get you the last 6 digits of the ID number.

 

If you have found my post helpful, please mark thumbs up.

 

Any other questions, just ask.

 

Thanks, Alan


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

Proud to be a Flownaut!


View solution in original post

Highlighted
New Member

Re: Extract last n-characters from Form input

Many thanks @AlanPs1 , I appreciate you taking the time to help.

 

After some more trial and error, I figured out that I needed to calculate the index value for the substring and then arrived at the same solution as you(well almost). I didn't specify INT in the last subsubstring value but it worked either way. 

 

Solution.jpg

Highlighted
Resident Rockstar
Resident Rockstar

Re: Extract last n-characters from Form input

That's great @scottgm23 .

int() not always required but Flow tends to output to string unless told otherwise so it's a safer option a lot of the time.

I'm glad you have it working!

 

Happy Flowing!

Thanks, Alan


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

Proud to be a Flownaut!


Highlighted
New Member

Re: Extract last n-characters from Form input

Stumbled upon this post when trying to find a solution for the problem I'm facing which is very similar to this one that @scottgm23 was facing. and thanks @AlanPs1 for the solution.

 

After some running some tests, I figured out actually there is a way to reduce the steps by merging the last two steps. Using @AlanPs1 's solution above as example, i.e.

 

 

 

substring(outputs('Compose_Input'), int(sub(length(outputs('Compose_Input')), 6)), 6)

 

 

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

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!

Top Solution Authors
Top Kudoed Authors
Users online (8,202)