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 / Using initialize varia...
Power Automate
Unanswered

Using initialize variable to get email from column value

(2) ShareShare
ReportReport
Posted on by 24
Hi there,
 
I have a flow using initialize variable String with the following expression:
 
if (equals(item()?['field_8'], 'Name1'), 'Name1_email@address.com',
if (equals(item()?['field_8'], 'Name2'), 'Name2_email@address.com',
if (equals(item()?['field_8'], 'Name3'), 'Name3_email@address.com',
if (equals(item()?['field_8'], 'Name4'), 'Name4_email@address.com',
if (equals(item()?['field_8'], 'Name5'), 'Name5_email@address.com','')))))
 
I want to use the variable output for the Send an email action but the output is showing null even though the field has Name1. 
 
Any help appreciated
Categories:
I have the same question (0)
  • Suggested answer
    Pstork1 Profile Picture
    68,707 Most Valuable Professional on at
    Two things. 1) the comparison you are doing is case sensitive so that may be why the match isn't being made.  Usually its a good idea to convert everything to upper or lower case when doing a comparison. 2) You have all the nested IF's, but you don't really have what to do if they are true or false.  They just daisy chain to another if either way and the final if doesn't include any values for true or false.

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     
  • YM-29012021-0 Profile Picture
    24 on at
     Thanks for your reply. What is best practice to not have the Ifs daisy chained? I'll give the case conversion a go and see if that works.
  • Pstork1 Profile Picture
    68,707 Most Valuable Professional on at
    One way to avoid nested ifs is to use a switch.  Since you are testing the same value at each level you can use a switch and just add a case for each different matching value.
    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     
  • Suggested answer
    w.p Profile Picture
    8,339 Super User 2025 Season 2 on at
    the function item()?['field_8'] => null, it doesn't work with Get Items.
    replace with select with filter actions.
  • YM-29012021-0 Profile Picture
    24 on at
     Thanks for your response, can you suggest an alternative here?
  • w.p Profile Picture
    8,339 Super User 2025 Season 2 on at
    Not sure about the condition, and it looks like you are trying to send an email one by one instead of all at once.
    Can you share screenshots of your list and explain a bit more of what you are trying to achieve?
  • YM-29012021-0 Profile Picture
    24 on at
     
    Sure, here's a bit more of explanation, the idea of the flow is to send them an email if the task is overdue and not complete. Field 8 contains an employee Name that is assigned that task. If the Due Date of that task is past today, they are notified by email. I had used a similar expression when using Get Responses from a form but this the first time with a list.
     
    Get items:
     
    The condition is as below:
  • w.p Profile Picture
    8,339 Super User 2025 Season 2 on at

    I'm guessing the field_8 is a single line of text column type, that's why you are using nested IF statements to get the static email and decided not to use person column type for some reasons.

    @Pstork1 suggested one way to avoid nested ifs is to use a switch, have you tried it?

  • Chriddle Profile Picture
    8,436 Super User 2025 Season 2 on at
    Don't use if statements at all. Use a map like this:
     
     
    My Compose "Get items" mimics your Get items action.
    {
    "body": [
      {"Name": "Name1", "DueDate": "2024-12-01"},
      {"Name": "Name2", "DueDate": "2025-12-01"},
      {"Name": "Name3", "DueDate": "2025-03-31"}
    ]
    }
     
    "Email" is a Compose with the map.
    {
    "Name1": "Name1_email@address.com",
    "Name2": "Name2_email@address.com",
    "Name3": "Name3_email@address.com",
    "Name4": "Name4_email@address.com",
    "Name5": "Name5_email@address.com"
    }
     
     
    "Select" adds the emails to the values of Get items.
    From:
    body('Get_items')
    Map:
    addProperty(
    	item(),
    	'Email',
    	outputs('Email')[item()['Name']]
    )
     
    The result is a collection of values ​​containing the email addresses that you can filter (if you haven't already done so in the "Get Items") and then send the corresponding emails to.
  • Suggested answer
    w.p Profile Picture
    8,339 Super User 2025 Season 2 on at
     
     
     
     
    Full Name: item()?['FullName']
    Email: outputs('StaticEmailList')?[toLower(item()?['FullName'])]
    ID: item()?['ID']
     
     
     
     
    To: item()?['Email']
    Full Name: item()?['Full Name']
    ID: item()?['ID']
     
     

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