Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Answered

How to change Last Name to First Name in power automate?

(0) ShareShare
ReportReport
Posted on by 65

I have a flow that when an item is created, an email is sent to the person who created the item.
In the body of the email to be sent, I put the "Created by", but the format is first the "last name" and then the "first name", but I would like to have the first name and then the last name. Is there any way to create an expression to change this?

 

Example:
how it is sent: Gartner, Henrique
how would I like it to be: Henrique Gartner

 

Thanks

  • Verified answer
    Expiscornovus Profile Picture
    31,639 Most Valuable Professional on at
    Re: How to change Last Name to First Name in power automate?

    Hi @hgartner,

     

    Can you use the following expression for the names with the bracketed reference:

    concat(replace(split(split(outputs('Compose'), ',')[1], '[')[0], ' ', ''), ' ', split(outputs('Compose'), ',')[0])
  • hgartner Profile Picture
    65 on at
    Re: How to change Last Name to First Name in power automate?

    Ahh, I get it. I was using the output of compose to add to the message body. I made the expression directly in the body of the message and it worked.

    Just a note, I forgot to mention that the name is made up of a bracketed reference. Would it be possible to delete?

    For example: Gartner, Henrique [Netherlands]
    Result after applying the expression: Henrique Gartner

  • Verified answer
    Expiscornovus Profile Picture
    31,639 Most Valuable Professional on at
    Re: How to change Last Name to First Name in power automate?

    Hi @hgartner,

     

    That compose action is just an example of presenting the new name. You should also be able to use that expression directly in the body (corpo) of the e-mail action via the expression (expressão) editor.

  • hgartner Profile Picture
    65 on at
    Re: How to change Last Name to First Name in power automate?

    Yes, but the output of compose 2 does not appear in dynamic content to add it to the body of the message to be sent in the email.

     

    hgartner_0-1631899639524.png

     

  • Expiscornovus Profile Picture
    31,639 Most Valuable Professional on at
    Re: How to change Last Name to First Name in power automate?

    Hi @hgartner ,

     

    Can you place the second compose action also within the apply to each action?

  • hgartner Profile Picture
    65 on at
    Re: How to change Last Name to First Name in power automate?

    Hi Dennis,

    Thank you very much. The expression works for the Compose whose value is entered manually. But when I put a value from a sharepoint list, it gives the following error in the split:

     

    Could not process template language expressions in 'Compose_2' entries of action in row '1' and column '27301': 'Template language function 'split' expects first parameter to be of type string . The value provided is of type 'Array'.

     

    hgartner_0-1631896673280.png

     

  • Verified answer
    Expiscornovus Profile Picture
    31,639 Most Valuable Professional on at
    Re: How to change Last Name to First Name in power automate?

    Hi @hgartner,

     

    I forgot about the leading space character.

     

    I have added a replace function for that in the expression:

    concat(replace(split(outputs('Compose'), ',')[1], ' ', ''), ' ', split(outputs('Compose'), ',')[0])

     

  • Verified answer
    Expiscornovus Profile Picture
    31,639 Most Valuable Professional on at
    Re: How to change Last Name to First Name in power automate?

    Hi @hgartner,

     

    You could use an expression for that with a split and concat function. Obviously this only works if there is always a comma character as a separator.

     

    concat(split(outputs('Compose'), ',')[1], ' ', split(outputs('Compose'), ',')[0])

     

    split_displayname.png

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,618 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,962 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow