web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Power Automate Substri...
Power Automate
Unanswered

Power Automate Substring Issues

(0) ShareShare
ReportReport
Posted on by 2

Hello Community,

 

Previously I had designed a workflow that was able to extract key bits of information from an email and store it in Sharepoint. However, I am no longer able to get this to work. Not sure what has changed. The email contains the following Information:

 

Enter your email to subscribe: test1@test.co.uk
Referral Code:
Consent: on
utm_source:

---
Date: April 15, 2021
Time: 3:29 pm

 

The flow is shown below: Whilst the error occurs on the email: The flow is not working as designed. As an example, the Get UTM Source should get the data after UTM_Source in the email even if it is blank.

 

automate_1.PNG

 

The expression for get utm_source is as follows

trim(trim(substring(body('Html_to_text'),add(indexOf(body('Html_to_text'),'utm_source '),11),sub(indexOf(body('Html_to_text'),'---'),add(indexOf(body('Html_to_text'),'utm_source '),11)))))

 

automate_2.PNG

 

The expression for get email is:

trim(substring(body('Html_to_text'),add(indexOf(body('Html_to_text'),'Enter your email to subscribe: '),31),sub(indexOf(body('Html_to_text'),'Referral Code: '),add(indexOf(body('Html_to_text'),'Enter your email to subscribe: '),31))))

 

Any help to resolve this is appreciated. 

Categories:
I have the same question (0)
  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Hi @agrawa1a 

     

    Your alternative is to split the string into an array.

     

    DamoBird365_0-1618771183682.png

     

    If you want to give this a go quickly, copy (Ctrl +C) and paste the below code into a flow, New Step -> My ClipBoard and Ctrl + V

     

    {"id":"db72f9db-4651-446d-9375-f93f-ee2e1725","brandColor":"#8C3900","connectionReferences":{},"connectorDisplayName":"Control","icon":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KIDxwYXRoIGQ9Im0wIDBoMzJ2MzJoLTMyeiIgZmlsbD0iIzhDMzkwMCIvPg0KIDxwYXRoIGQ9Im04IDEwaDE2djEyaC0xNnptMTUgMTF2LTEwaC0xNHYxMHptLTItOHY2aC0xMHYtNnptLTEgNXYtNGgtOHY0eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+DQo=","isTrigger":false,"operationName":"DamoBird365","operationDefinition":{"type":"Scope","actions":{"Compose":{"type":"Compose","inputs":"Enter your email to subscribe: test1@test.co.uk\nReferral Code:\nConsent: on\nutm_source:\n\n---\nDate: April 15, 2021\nTime: 3:29 pm","runAfter":{}},"ReturnLine":{"type":"Compose","inputs":"\n","runAfter":{"Compose":["Succeeded"]}},"Split2Array":{"type":"Compose","inputs":"@split(outputs('Compose'),outputs('ReturnLine'))","runAfter":{"ReturnLine":["Succeeded"]}},"Select":{"type":"Select","inputs":{"from":"@outputs('Split2Array')","select":"@split(item(),': ')?[1]"},"runAfter":{"Split2Array":["Succeeded"]},"description":"split(item(),': ')?[1]"},"AValue":{"type":"Compose","inputs":"@{body('Select')?[0]}\nbody('Select')?[0] etc 1,2,3\n@{body('Select')?[1]}\n@{body('Select')?[2]}\n@{body('Select')?[3]}","runAfter":{"Select":["Succeeded"]}}},"runAfter":{}}}

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 780

#2
Valantis Profile Picture

Valantis 668

#3
Haque Profile Picture

Haque 601

Last 30 days Overall leaderboard