cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Replace and concatenate domain name

 

Is there a expression to remove the @ sign at the front and then replace the space between two names to a '.' and at the end of the name add @ domain name. Also to trim out anything after the last name.

 

eg- 

 

@ Testing Person this is a test comment -> Testing.Person@gmail.com

1 ACCEPTED SOLUTION

Accepted Solutions
eliotcole
Super User
Super User

OK, there you can see the href link closure and the   (which isn't required to be honest) which are likely causing you issues, here.

 

I would raise that as an issue, separately, to the Power Automate team elsewhere in this forum.

 

Link back to this post to help them get context on why it's not presenting the right data. 🙂

 

I'm seeing what you're seeing based on that HTML to plain text thing, and it's clearly not working right.

 

Here's the HTTP codes that it's got there instead of spaces:

testing.person%C2%A0this%40gmail.com%20space

 

 

Workaround & Fix

I have done a quick check and I think this should fix it for you, in your HTML to text action delete the System_History item that is there, and replace it with an expression, and use this:

replace(body('Parse_JSON')?['System_History'], ' ', ' ')

What that does is still use the same field, but if there is any usage of the   HTML that is used to make spaces, then it will simply replace those characters with an actual space.

 

Also, I've somewhat optimised the emailVAR expression. You should be fine with what you have, but you can try this, too (maybe in a separate place?):

concat(join(take(split(substring(toLower(variables('inputStringVAR')), add(indexOf(toLower(variables('inputStringVAR')), '@'), 1)), ' '), 2), '.'), '@', variables('domainVAR'))

View solution in original post

16 REPLIES 16
eliotcole
Super User
Super User

Assuming that your email is in a variable called emailVAR, then:

 

trim(replace(first(split(variables('emailVAR'), '@')), '.', ' '))

 

 

If you wanted to create that whole line, then:

 

concat('@ ', trim(replace(first(split(variables('emailVAR'), '@')), '.', ' ')), ' this is a test comment -> ', variables('emailVAR'))

 

 

If all the emails were definitely split by given and family name respectively, then you could define a givenVAR string variable with:

first(split(first(split(variables('emailVAR'), '@')), '.'))

And you could define family with

last(split(first(split(variables('emailVAR'), '@')), '.'))

basic expressions.jpg

 

Anonymous
Not applicable

I think there is a misunderstanding, what I am trying to achieve is that, assuming that you only know persons first name and last name, create an email address from it. Hard coding the domain is fine.

 

This is the output of the HTML to Text 

@ Testing Person this is a test comment 

 

I want to convert the above to 

 

testing.person@gmail.com  

Ah, my mistake, that's easier, then.

 

Solution

If we can assume:

  1. The input text is always validatedly set in the the above forma
  2. The following variables exist
    1. domainVAR - string - has the domain
    2. inputStringVAR - string - has the input
    3. emailVAR - string - is empty

... then we can use the following to set the emailVAR variable:

concat(first(split(substring(variables('inputStringVAR'), 2), ' ')), '.', first(skip(split(substring(variables('inputStringVAR'), 2), ' '), 1)), '@', variables('domainVAR'))

 

More Options

If you want it in lower case, then use:

concat(first(split(substring(toLower(variables('inputStringVAR')), 2), ' ')), '.', first(skip(split(substring(toLower(variables('inputStringVAR')), 2), ' '), 1)), '@', variables('domainVAR'))

 

If you also have empty givenVAR and familyVAR string variables set for the names (using the parts above):

concat(toLower(variables('givenVAR')), '.', toLower(variables('familyVAR')), '@', variables('domainVAR'))

You may wish to do this to make the logic more apparent to future users, and/or to re-use the names elsewhere in the flow.

Anonymous
Not applicable

@eliotcole

 

unfortunately this is the output

 

testing.person this@gmail.com

 

input 

 

@Testing Person this is just a test

Anonymous
Not applicable

You can make this work by splitting up your input string and putting it into an array.

I did this using an array called 'words', created with the expression:

split(substring(variables('inputStringVAR'), 2), ' ')

Once you've done that you can isolate firstname 'Testing':

first(variables('words'))

and the lastname 'Person':

first(skip(variables('words'), 1))

if you had the domain in a string variable, you can now concatinate:

concat( first(variables('words')), '.', first(skip(variables('words'), 1)), '@', variables('domainVAR'))

 

JeroenE_0-1629471556021.png

 

And the output:

JeroenE_1-1629471634180.png

 

Hope this helps.

Please flag as solution if this works for you. It'll help others find this.

 

 

 

 

Anonymous
Not applicable

@Anonymous  This is the output I get

 

[
  "esting",
  "Person this",
  "is",
  "a",
  "test",
  "comment\n\n"
]
 
 
 
eliotcole
Super User
Super User

@Anonymous, huh, that's odd. Let's try something.

 

These are the exact actions that I just took from my text above.

 

  1. Create a new flow.
  2. Define a string variable: inputStringVAR
  3. Enter the exact text you gave me earlier with no space at the front in the inputStringVAR value:
    @ Testing Person this is a test comment
  4. Define a string variable: domainVAR
  5. Enter this in the domainVAR value:
    gmail.com
  6. Add a Compose action
  7. Create an expression in the Compose action and paste in the below code
  8. Save then run this new flow.

 

 

concat(first(split(substring(toLower(variables('inputStringVAR')), 2), ' ')), '.', first(skip(split(substring(toLower(variables('inputStringVAR')), 2), ' '), 1)), '@', variables('domainVAR'))

 

 

Just report back with what happens if you can? 🙂

 

 

---

 

FYI 1 - Avoiding Leading Spaces

If we want to eliminate the chance that the inputStringVAR has erroneous spaces before and after we can simply add a couple of trim() functions, like so:

 

concat(first(split(substring(toLower(trim(variables('inputStringVAR'))), 2), ' ')), '.', first(skip(split(substring(toLower(trim(variables('inputStringVAR'))), 2), ' '), 1)), '@', variables('domainVAR'))

 

FYI 2 - Avoiding Substring

Substring is fine, but finickity, it means that lengths need to be exact each time, and often you'll end up doing more work in the long run. That doesn't mean it won't work, but it'll have more upkeep.

 

FYI 3 - Shortening Using take() and skip()

There is a shorter way of doing it using take() and skip() functions in the expression. The take() function will return the first few items of an array, and the skip() function will jump over them, you define how many this is after the comma:

:

concat(join(take(skip(split(toLower(trim(variables('inputStringVAR'))), ' '), 1), 2), '.'), '@', variables('domainVAR'))

 

Anonymous
Not applicable

@eliotcole I converted the input to an array to see what the output look like in the following, as you can see the second item in the array has " this" where it should be "Person"

 

[
  "Testing",
  "Person this",
  "is",
  "a",
  "test",
  "comment\n\n"
]
eliotcole
Super User
Super User

Have you followed the steps that I just posted above?

 

Because when I paste that text, as written, on my instructions above, with the code, above, in a new flow, I get different results.

 

Could you show me a screenshot of your new flow, please? 🙂

 

Anonymous
Not applicable

@eliotcole  

PowerAutomateUs_1-1629477882134.png

 

 

eliotcole
Super User
Super User

OK, thanks, this is what your main issue is (it would seem) it's that the text that you're putting in your inputStringVAR is not the exact text that we mentioned above, it has different characters in it.

 

You'd mentioned that the text was going to be consistent, so we worked with that, however what we're seeing is not the text mentioned.

 

If you remove that 'The plain text c...' and entered what I mention above, you'll see that it works.

 

Could you please send me the data from that 'System_History' field that you're sending into the HTML to text action?

Anonymous
Not applicable

When I replace the Html to text with "@ Testing Person this is a test comment" the output shows the correct email.

 

<p><div><a href="#" data-vss-mention="version:2.0,c2fc253f-6644-6f52-9366-318d9b406142">@Testing Person</a>&nbsp;this is a test</div></p>

 

output when converted 

 

@testing Person this is  a test

 

 

eliotcole
Super User
Super User

OK, there you can see the href link closure and the &nbsp; (which isn't required to be honest) which are likely causing you issues, here.

 

I would raise that as an issue, separately, to the Power Automate team elsewhere in this forum.

 

Link back to this post to help them get context on why it's not presenting the right data. 🙂

 

I'm seeing what you're seeing based on that HTML to plain text thing, and it's clearly not working right.

 

Here's the HTTP codes that it's got there instead of spaces:

testing.person%C2%A0this%40gmail.com%20space

 

 

Workaround & Fix

I have done a quick check and I think this should fix it for you, in your HTML to text action delete the System_History item that is there, and replace it with an expression, and use this:

replace(body('Parse_JSON')?['System_History'], '&nbsp;', ' ')

What that does is still use the same field, but if there is any usage of the &nbsp; HTML that is used to make spaces, then it will simply replace those characters with an actual space.

 

Also, I've somewhat optimised the emailVAR expression. You should be fine with what you have, but you can try this, too (maybe in a separate place?):

concat(join(take(split(substring(toLower(variables('inputStringVAR')), add(indexOf(toLower(variables('inputStringVAR')), '@'), 1)), ' '), 2), '.'), '@', variables('domainVAR'))
Anonymous
Not applicable

@eliotcole When the Html to text is replaced with the given expression I get this error 

 

Unable to process template language expressions in action 'Initialize_variable_4' inputs at line '1' and column '20025': 'The template language expression 'body('Html_to_text')?['body']' cannot be evaluated because property 'body' cannot be selected. Property selection is not supported on values of type 'String'.

 

PowerAutomateUs_0-1629511386551.png

 

PowerAutomateUs_1-1629511403733.png

 

eliotcole
Super User
Super User

I'd guess that looks like your Html to text didn't receive any data on that run, mate.

Anonymous
Not applicable

just realized it was the missing ['fields']? that was causing it. 

 

replace(body('Parse_JSON')?['fields']?['System_History'], '&nbsp;', ' ')

 

In your new concat expression this is the new output any way to trim out the </a> tag

 

testing.person</a>@gmail.com

Helpful resources

Announcements

Community Roundup: A Look Back at Our Last 10 Tuesday Tips

As we continue to grow and learn together, it's important to reflect on the valuable insights we've shared. For today's #TuesdayTip, we're excited to take a moment to look back at the last 10 tips we've shared in case you missed any or want to revisit them. Thanks for your incredible support for this series--we're so glad it was able to help so many of you navigate your community experience!   Getting Started in the Community An overview of everything you need to know about navigating the community on one page!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Ranks and YOU Have you ever wondered how your fellow community members ascend the ranks within our community? We explain everything about ranks and how to achieve points so you can climb up in the rankings! Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Powering Up Your Community Profile Your Community User Profile is how the Community knows you--so it's essential that it works the way you need it to! From changing your username to updating contact information, this Knowledge Base Article is your best resource for powering up your profile. Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Blogs--A Great Place to Start There's so much you'll discover in the Community Blogs, and we hope you'll check them out today!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Unlocking Community Achievements and Earning Badges Across the Communities, you'll see badges on users profile that recognize and reward their engagement and contributions. Check out some details on Community badges--and find out more in the detailed link at the end of the article! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Blogging in the Community Interested in blogging? Everything you need to know on writing blogs in our four communities! Get started blogging across the Power Platform communities today! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Subscriptions & Notifications We don't want you to miss a thing in the community! Read all about how to subscribe to sections of our forums and how to setup your notifications! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Getting Started with Private Messages & Macros Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Community User Groups Learn everything about being part of, starting, or leading a User Group in the Power Platform Community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Update Your Community Profile Today! Keep your community profile up to date which is essential for staying connected and engaged with the community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Thank you for being an integral part of our journey.   Here's to many more Tuesday Tips as we pave the way for a brighter, more connected future! As always, watch the News & Announcements for the next set of tips, coming soon!    

Calling all User Group Leaders and Super Users! Mark Your Calendars for the next Community Ambassador Call on May 9th!

This month's Community Ambassador call is on May 9th at 9a & 3p PDT. Please keep an eye out in your private messages and Teams channels for your invitation. There are lots of exciting updates coming to the Community, and we have some exclusive opportunities to share with you! As always, we'll also review regular updates for User Groups, Super Users, and share general information about what's going on in the Community.     Be sure to register & we hope to see all of you there!

April 2024 Community Newsletter

We're pleased to share the April Community Newsletter, where we highlight the latest news, product releases, upcoming events, and the amazing work of our outstanding Community members.   If you're new to the Community, please make sure to follow the latest News & Announcements and check out the Community on LinkedIn as well! It's the best way to stay up-to-date with all the news from across Microsoft Power Platform and beyond.    COMMUNITY HIGHLIGHTS   Check out the most active community members of the last month! These hardworking members are posting regularly, answering questions, kudos, and providing top solutions in their communities. We are so thankful for each of you--keep up the great work! If you hope to see your name here next month, follow these awesome community members to see what they do!   Power AppsPower AutomateCopilot StudioPower PagesWarrenBelzDeenujialexander2523ragavanrajanLaurensMManishSolankiMattJimisonLucas001AmikcapuanodanilostephenrobertOliverRodriguestimlAndrewJManikandanSFubarmmbr1606VishnuReddy1997theMacResolutionsVishalJhaveriVictorIvanidzejsrandhawahagrua33ikExpiscornovusFGuerrero1PowerAddictgulshankhuranaANBExpiscornovusprathyooSpongYeNived_Nambiardeeksha15795apangelesGochixgrantjenkinsvasu24Mfon   LATEST NEWS   Business Applications Launch Event - On Demand In case you missed the Business Applications Launch Event, you can now catch up on all the announcements and watch the entire event on-demand inside Charles Lamanna's latest cloud blog.   This is your one stop shop for all the latest Copilot features across Power Platform and #Dynamics365, including first-hand looks at how companies such as Lenovo, Sonepar, Ford Motor Company, Omnicom and more are using these new capabilities in transformative ways. Click the image below to watch today!   Power Platform Community Conference 2024 is here! It's time to look forward to the next installment of the Power Platform Community Conference, which takes place this year on 18-20th September 2024 at the MGM Grand in Las Vegas!   Come and be inspired by Microsoft senior thought leaders and the engineers behind the #PowerPlatform, with Charles Lamanna, Sangya Singh, Ryan Cunningham, Kim Manis, Nirav Shah, Omar Aftab and Leon Welicki already confirmed to speak. You'll also be able to learn from industry experts and Microsoft MVPs who are dedicated to bridging the gap between humanity and technology. These include the likes of Lisa Crosbie, Victor Dantas, Kristine Kolodziejski, David Yack, Daniel Christian, Miguel Félix, and Mats Necker, with many more to be announced over the coming weeks.   Click here to watch our brand-new sizzle reel for #PPCC24 or click the image below to find out more about registration. See you in Vegas!       Power Up Program Announces New Video-Based Learning Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram. These include a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the image below to find out more!   UPCOMING EVENTS Microsoft Build - Seattle and Online - 21-23rd May 2024 Taking place on 21-23rd May 2024 both online and in Seattle, this is the perfect event to learn more about low code development, creating copilots, cloud platforms, and so much more to help you unleash the power of AI.   There's a serious wealth of talent speaking across the three days, including the likes of Satya Nadella, Amanda K. Silver, Scott Guthrie, Sarah Bird, Charles Lamanna, Miti J., Kevin Scott, Asha Sharma, Rajesh Jha, Arun Ulag, Clay Wesener, and many more.   And don't worry if you can't make it to Seattle, the event will be online and totally free to join. Click the image below to register for #MSBuild today!   European Collab Summit - Germany - 14-16th May 2024 The clock is counting down to the amazing European Collaboration Summit, which takes place in Germany May 14-16, 2024. #CollabSummit2024 is designed to provide cutting-edge insights and best practices into Power Platform, Microsoft 365, Teams, Viva, and so much more. There's a whole host of experts speakers across the three-day event, including the likes of Vesa Juvonen, Laurie Pottmeyer, Dan Holme, Mark Kashman, Dona Sarkar, Gavin Barron, Emily Mancini, Martina Grom, Ahmad Najjar, Liz Sundet, Nikki Chapple, Sara Fennah, Seb Matthews, Tobias Martin, Zoe Wilson, Fabian Williams, and many more.   Click the image below to find out more about #ECS2024 and register today!     Microsoft 365 & Power Platform Conference - Seattle - 3-7th June If you're looking to turbo boost your Power Platform skills this year, why not take a look at everything TechCon365 has to offer at the Seattle Convention Center on June 3-7, 2024.   This amazing 3-day conference (with 2 optional days of workshops) offers over 130 sessions across multiple tracks, alongside 25 workshops presented by Power Platform, Microsoft 365, Microsoft Teams, Viva, Azure, Copilot and AI experts. There's a great array of speakers, including the likes of Nirav Shah, Naomi Moneypenny, Jason Himmelstein, Heather Cook, Karuana Gatimu, Mark Kashman, Michelle Gilbert, Taiki Y., Kristi K., Nate Chamberlain, Julie Koesmarno, Daniel Glenn, Sarah Haase, Marc Windle, Amit Vasu, Joanne C Klein, Agnes Molnar, and many more.   Click the image below for more #Techcon365 intel and register today!     For more events, click the image below to visit the Microsoft Community Days website.      

Tuesday Tip | Update Your Community Profile Today!

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   We're excited to announce that updating your community profile has never been easier! Keeping your profile up to date is essential for staying connected and engaged with the community.   Check out the following Support Articles with these topics: Accessing Your Community ProfileRetrieving Your Profile URLUpdating Your Community Profile Time ZoneChanging Your Community Profile Picture (Avatar)Setting Your Date Display Preferences Click on your community link for more information: Power Apps, Power Automate, Power Pages, Copilot Studio   Thank you for being an active part of our community. Your contributions make a difference! Best Regards, The Community Management Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Super User of the Month | Ahmed Salih

We're thrilled to announce that Ahmed Salih is our Super User of the Month for April 2024. Ahmed has been one of our most active Super Users this year--in fact, he kicked off the year in our Community with this great video reminder of why being a Super User has been so important to him!   Ahmed is the Senior Power Platform Architect at Saint Jude's Children's Research Hospital in Memphis. He's been a Super User for two seasons and is also a Microsoft MVP! He's celebrating his 3rd year being active in the Community--and he's received more than 500 kudos while authoring nearly 300 solutions. Ahmed's contributions to the Super User in Training program has been invaluable, with his most recent session with SUIT highlighting an incredible amount of best practices and tips that have helped him achieve his success.   Ahmed's infectious enthusiasm and boundless energy are a key reason why so many Community members appreciate how he brings his personality--and expertise--to every interaction. With all the solutions he provides, his willingness to help the Community learn more about Power Platform, and his sheer joy in life, we are pleased to celebrate Ahmed and all his contributions! You can find him in the Community and on LinkedIn. Congratulations, Ahmed--thank you for being a SUPER user!

Users online (5,517)