cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
fcaldero
Level: Powered On

extracting the First Name from SharePoint List Item

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User
Dual Super User

Re: extracting the First Name from SharePoint List Item

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.



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

View solution in original post

2 REPLIES 2
Dual Super User
Dual Super User

Re: extracting the First Name from SharePoint List Item

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.



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

View solution in original post

Community Support Team
Community Support Team

Re: extracting the First Name from SharePoint List Item

 

Hi @fcaldero ,

 

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,

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.

Helpful resources

Announcements
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
Users Online
Currently online: 319 members 6,052 guests
Please welcome our newest community members: