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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / extracting the First N...
Power Automate
Unanswered

extracting the First Name from SharePoint List Item

(0) ShareShare
ReportReport
Posted on by

Hello,
I have a flow getting values from a  SP list item.  The values retrieved through a series of Apply to Each Controls get fed in to an email message.  These values include email address, the 'DisplayName' of the individual receiving the email, the 'DisplayName' of the person sending it, and a URL link to a survey.  I would like to extract the first name of the Display name of the individual receiving the email to make it more personal.  Instead of "Dear John Doe," I would like the email to say: "Dear John,"

Tried using a compose action and typing in the following expression: first(split(body('Apply_to_each')?['DisplayName'],' ')) where 'Apply_to_each' is based on the location within the flow.  The error received is the following:

 

"InvalidTemplate. Unable to process template language expressions in action 'Compose' inputs at line '1' and column '2656': 'The template language function 'split' expects its first parameter to be of type string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#split for usage details.'."

 

Flow1.JPG

 

Categories:
I have the same question (0)
  • Verified answer
    Pstork1 Profile Picture
    68,697 Most Valuable Professional on at

    YOu've got several Apply to Each Loops in your screenshot.  Which one are you trying to get the First name from?  It looks like its the Apply to Each 7 loop.  If it is, then your JSON should look more like this

    first(split(body('Apply_to_each 7')?['value']?['DisplayName'],' ')) 

    That's probably not exact, but it should be close.  Do a Peek code on the Apply to Each Loop and  you should see something similar to the JSON above.

  • v-bacao-msft Profile Picture
    on at

     

    Hi @Anonymous ,

     

    You could click on the peek code of Send an email 2 action and get the actual expression corresponding to Dynamic content.

    Then use it to replace "body('Apply_to_each')?['DisplayName']".

     

    For example:

    80.PNG81.PNG

    Hope it helps.

     

    Best Regards,

  • Oberke Profile Picture
    2 on at

    Is there an expression I could use to get the First Name and Last initial from a Display name ?

  • Pstork1 Profile Picture
    68,697 Most Valuable Professional on at

    The expression I listed will give you the first name from display name. It splits DisplayName on a space and returns the first item in the array which is the FirstName.  The last name could be retrieved using the same expression if you substitute Last() for First().  Then you would need to grab the first letter of that for the initial.

    first(split(body('Apply_to_each 7')?['value']?['DisplayName'],' ')) 

     

  • Community Power Platform Member Profile Picture
    on at

    It's basically like v-bacao-msft left us, for this exact example, but in general, the Person fields in SharePoint are "lastName, firstName", so you have to do it like this, if you were doing it from the "Created By" of your list item:

    last(split(triggerBody()?['Author']?['DisplayName'],' ')) 

    For example, if it was "Doe, John", it will split on the space and get the last piece: John

    If you wanted the last name, in this example, put "first" instead of "last" at the beginning of that line of code. Then you could use it like "Dear Mr. Doe".

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard