cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
CodyS
Level: Power Up

Flow: Find / Isolate Value within a String

Hello All! 

 

I'm trying to leverage our use of ASANA as a project management tool with our clients through FLOW to send out an e-mail when projects are completed asking for the client to complete a survey / ranking.  Problem is - the information I need to send to an individual is located in a single attribute ("note").  In order to set up the pretty simple flow, I need to isolate the 'email' value provided in this document.  I can't wrap my brain around which direction to lean...

 

Currently the string looks like this:

 

----

 

Project Name:
My really cool project
 
Name:
First: John
Last: Smith
 
Organization Name:
Super Cool Awesome Company
 
Email:
johnsmith@test.com
 
Phone Number:
999-999-9999
 
Completed electronic file is due to you by::
2019-11-15
 
----
 
Basically I just need to capture the value of e-mail from this whole string using an expression.  Possible? Any advice?
 
 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Flow: Find / Isolate Value within a String

 

Hi @CodyS ,

 

Please try the following method, using the fixed field name as the split point to extract the email.

Use the split() function to split the email body with "Email:" and "Phone Number:" and extract the email.

Expression reference:

trim(split(split(body('Html_to_text'),'Email:')[1],'Phone Number:')[0])

Image reference:

81.PNG

Hope it helps.

 

Best Regards, 

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
Highlighted
Super User
Super User

Re: Flow: Find / Isolate Value within a String

@CodyS I believe that you could do the following:

  1. Use the indexOf expression to find the location of the string Email:
  2. Use the indexOf expression to find the location of the string PhoneNumber:
  3. Use the substringOf expression to grab all text between the two
  4. Use the trim expression on the result

You may/may not need to use the HTML to text action on your content before your start.

Let me know if you need an example.

 

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
CodyS
Level: Power Up

Re: Flow: Find / Isolate Value within a String

Thanks @ScottShearer  - that explanation totally makes sense. Thanks for listing it out.  As it's my first time building an advanced expression in FLOW, I'm having a hard time conceptualizing how I would nest a lot of these expressions - would you suggest working from the bottom up and layering the pieces in?

 

I tried putting them together that way and wound up with:

trim(substring(triggerBody()?['notes'],indexOf(triggerBody()?['notes'], 'Email:'),indexOf(triggerBody()?['notes'], 'Phone Number:')))
 
but it didn't return just the e-mail - it returned a longer string, akin to:
"Email: jsmith@uvm.edu Phone Number: 9999999999 Completed electronic file is due to you by:: 2019-11-04 "
 
Close...but my brain just isn't quite there.  Any advice?
Super User
Super User

Re: Flow: Find / Isolate Value within a String

@CodyS 

To simply things, you might try using variables or compose actions for each piece and doing it one step at a time.  When you have that working, then put it all together into a single expression and remove the variables.  So, create a variable for indexOf(Start) and another for indexOf(End), etc..  Then, reference those two variables in the substring action.  It is easier to get it working that way when you are first starting with expressions.  One thing to note, the indexOf will give you the position where a string starts - you'll need to do some math and add to that index so that you end up at the end of the string (if that makes sense...).

If you are having trouble, post what you have and we'll go from there.

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
Super User
Super User

Re: Flow: Find / Isolate Value within a String

@CodyS 

UPDATE:  In my screen shot below in the Find Email: String compose action, remove the : after Email in the expression.

Also, please note that if the text I am searching for appears elsewhere, then the results will not be what is expected.

 

Please see my example below.  All the expressions that I used can be seen in the action comments.  I started by putting your sample text in a compose action.  After doing this, I think it would be a really bad idea to have this all in one expression - leave it broken out per my example.  Post here if you need more help.

FindEmail1.jpgFindEmail2.jpgFindEmail3.jpgFindEmail4.jpg

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
Community Support Team
Community Support Team

Re: Flow: Find / Isolate Value within a String

 

Hi @CodyS ,

 

Please try the following method, using the fixed field name as the split point to extract the email.

Use the split() function to split the email body with "Email:" and "Phone Number:" and extract the email.

Expression reference:

trim(split(split(body('Html_to_text'),'Email:')[1],'Phone Number:')[0])

Image reference:

81.PNG

Hope it helps.

 

Best Regards, 

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Super User
Super User

Re: Flow: Find / Isolate Value within a String

@CodyS 

The solution provided by @v-bacao-msft is obviously a much better solution.  I keep forgetting to use split() …..

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
CodyS
Level: Power Up

Re: Flow: Find / Isolate Value within a String

@v-bacao-msft  - That worked perfectly with the slight alteration so that it can worth with the ASANA connection:

 

trim(split(split(triggerBody()?['notes'],'Email:')[1],'Phone Number:')[0])

 

Much thanks to both you and @ScottShearer for your help.  EXTREMELY helpful - both in finding the answer and in understanding how these expressions work. 🙂 

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Speakers, submit your sessions now! Call for speakers ends Feb. 10!

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!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,920)