cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Get Email Address from SharePoint List based on Department

I have 2 Sharepoint Lists.  

List1 - Item list with one of the columns for each item being (OwningDepartment)

List 2 - 2 Columns (Department)(DeptManager)

(OwningDepartment)(Department) have a 1 to 1 relationship theoretically but are not programed as a lookup in sharepoint.

 

When a new item is created I am trying to have flow look up the Department Manager in List2 based on what OwningDepartment is selected in List1 and send them an email.

 

Can anyone help with this???

 

Thanks

2 ACCEPTED SOLUTIONS

Accepted Solutions
m4ngo5
Advocate I
Advocate I

Hi @Teaners26,

 

 

Let's see what we can do.

 

I have my two lists.

List 1

List1-MakingAnItem.PNG

 

And List 2

 

DepartmentList-List2.PNG

 

  1. First you're going to create a trigger "When an item is created".  You're going to point this at your list 1,as you said.

    WhenAnItemIsCreated.PNG

  2. Create a "Get items" action and point it at your second list.  This is where the magic happens.  In the advanced options section, under filter query, you are going to create the filter. Your filter is going to look at items with a department value that equals the department value of the newly created item. 

    GetItemsAndFilter.PNG

    My filter query looked like this: 

    Dept_x0020_Manager eq '[Department Value]'


    There are three parts to this: 
    1. Dept_x0020_Manager - This is official name of your column in List 2 that you would like to search for a matching department name.
    2. eq - This is saying to look for things that have [value1] that equal [value2].
    3. '[Department Value]' - this returns the department value from the item that initiated the flow in List 1.  

    To find your column name (mine above was Dept_x0020_Manager), go to the list settings in List 2 and click on your "Dept Manager" column.  Then look at the end of your URL and you'll see it following "Field=".

    GoToListSettingsAndColumnSettings.PNG


    ColumnName.PNG


  3. Then create your email and fill in your variables. 

    You don't need to create the "Apply to each" piece.  It isn't necessary in this case but because our output was from a "Get items" action it could theoretically return multiple items, therefore when I created the next step, it created the "apply to each" loop.  This won't affect anything -- if there is only one item returned, it will only run once.

    SendEmailAboutNewItem.PNG

Let me know if this helps!

 

-Stuart

View solution in original post

I got this to work but i had to switch Dept_x0020_Manager with Department in the below expression.

 

Dept_x0020_Manager eq '[Department Value]'

View solution in original post

13 REPLIES 13
m4ngo5
Advocate I
Advocate I

Hi @Teaners26,

 

 

Let's see what we can do.

 

I have my two lists.

List 1

List1-MakingAnItem.PNG

 

And List 2

 

DepartmentList-List2.PNG

 

  1. First you're going to create a trigger "When an item is created".  You're going to point this at your list 1,as you said.

    WhenAnItemIsCreated.PNG

  2. Create a "Get items" action and point it at your second list.  This is where the magic happens.  In the advanced options section, under filter query, you are going to create the filter. Your filter is going to look at items with a department value that equals the department value of the newly created item. 

    GetItemsAndFilter.PNG

    My filter query looked like this: 

    Dept_x0020_Manager eq '[Department Value]'


    There are three parts to this: 
    1. Dept_x0020_Manager - This is official name of your column in List 2 that you would like to search for a matching department name.
    2. eq - This is saying to look for things that have [value1] that equal [value2].
    3. '[Department Value]' - this returns the department value from the item that initiated the flow in List 1.  

    To find your column name (mine above was Dept_x0020_Manager), go to the list settings in List 2 and click on your "Dept Manager" column.  Then look at the end of your URL and you'll see it following "Field=".

    GoToListSettingsAndColumnSettings.PNG


    ColumnName.PNG


  3. Then create your email and fill in your variables. 

    You don't need to create the "Apply to each" piece.  It isn't necessary in this case but because our output was from a "Get items" action it could theoretically return multiple items, therefore when I created the next step, it created the "apply to each" loop.  This won't affect anything -- if there is only one item returned, it will only run once.

    SendEmailAboutNewItem.PNG

Let me know if this helps!

 

-Stuart

I got this to work but i had to switch Dept_x0020_Manager with Department in the below expression.

 

Dept_x0020_Manager eq '[Department Value]'

I'm glad you got it working!  

 

 

You're right about substituting Department for Department_x0020_Manager in the filter query. That was an error.

 

I can't remember if I tested my solution -- I probably didn't.

@m4ngo5 I have a nearly identical scenario except my analagous "Department" column in List 1 is a multiple selection lookup column of the department column of List 2. I want separate emails to be sent to each designated person.

 

I tried adding a For Each block to try to get it to run for each "Department" selected but it doesn't seem to be working

 

Do you know if/how I can modify the method you showed to my needs?

 

I know sharepoint isn't super friendly to lookup columns or multiple selections. 

 

Thanks!

@zz6If you still need help on this, I think I have the answer for you. 

 

When you have a list or library with lookup columns and you want an ODATA filter query to use these lookup columns, there is a special syntax for it.  You need to type in the name of the primary lookup column, a forward slash, then the name of the project lookup column (the child column). 

 

Here is a screenshot of one of my Flows.  The SharePoint library has a lookup column for Project Number, and a projected column for the Status which comes from the lookup against the Project Number list.  Syntax is ParentColumn/ChildColumn.

 

FlowScreenshot.png

 

If that's not what you're looking for, tag me and let me know!

Hi @m4ngo5 ,

 

why the filter query is not :

Department (in List2) eq '[Department Value]' (in list1)?

Thank you.

Hi @walking,

 

I'm a little confused, but I'll do my best to answer.  It looks like you may be pointing out that I did not answer @zz6 properly, so thank you for that.  I didn't address the case of filter queries directed at the primary lookup column, I addressed only the case of filter queries directed to child lookup columns.  For the primary lookup column, the syntax is the same as the child lookup columns, except you use a forward slash with title.  The syntax for my previous example would be:

 

ProjectNumber/title eq '[Value]'

 

And for the department example from @zz6, it would be:

 

Department/title eq '[Department Value]'

 

I tested that this works against lookup columns with multiple selection enabled.  If the filtered value is contained in the lookup column, the record will be returned.

 

You can filter for records that match both of two values in the department column by connecting two filter queries with an "and".  Likewise, an "or" substituted for "and" will filter for records that match either of two values. 

 

Building on this, you could use a for loop to append multiple filter queries to a string variable, and insert this string variable into the filter query field. This could be used to created a dynamic filter query that returns records that match a long list of values -- perhaps values which are not known until the flow runs.

@m4ngo5 

 

I'm really struggling to get my head around this. When I tried the first solution above I was told my column doesn't exist.

 

Essentially, I have a form that when filled out plugs the data into a sharepoint list. I have already been able to create a lookup as part of this flow, that identifies the submitters region, based on their country in O365.

 

As part of this I want an email to go to specific set of people based on region and job role. This is in another list in a matrix. Ideally, it would be good to keep the people for each region and role separate for ease of updating should someone leave or be replaced (me included).

 

The main list (list1) looks like this in essence (many other column besides):

list1.png

The contact list looks as follows (List2):

list2.png

 

Now I am creating an additional flow that looks for a new item being created in List 1. It should then look up the region in the title column of List 2, and add send to the email addresses of each person in each job role for that region. The job roles are people or contact fields, where the flow picks up the email address from the O365 contact. In testing I've not filled out the other fields yet other than one with my own person in.

 

My flow looks like below:

flow1.png

Now, when this flow is run, it fails with the message "Column NWE does not exist", and after batting my head against this for a few days, I cannot understand why...

 

results1.png

 

It's clearly picked something up from somewhere, but I am at a loss. I'd be very grateful for any support given by anyone!

@Dewi86If I understand this correctly, when an item is created in List 1, you want to notify a list of individuals from that region that this new item has been created.  So if the item in List 1 has a region of NWE, in List 2 there is an entry for the NWE region with columns that include the people you want to email including the Regional ISSO, IT Lead, Legal Rep, etc.

 

I'm noticing a few things that could be wrong:

  • Shouldn't Get Items be operating on List 2, not List 1?
  • You probably need single quotes around 'Region' in the filter query.
  • If Region in List 1 is a lookup column, there should be a column called 'Region Value' that you will probably need to use for your filter query instead of 'Region'

 

Please let me know if that helps!

Hi @m4ngo5 ,

 

Thanks for coming back to me so quickly!

 

I've looked over it and:

 

  • Get Items is List 2, mistake in my image
  • I added the quotes, no change
  • The Region column in list 1 is just a single line of text. Does this need to be a lookup column? I guess that would make sense, unless there is an alternate method I'll redo the flow used for the form data capture.
Anonymous
Not applicable

Hi, 

 

I have currently experiencing a similar situation which I want to resolve. I am trying to make a flow which triggers an email to Department Managers as well as their respective team members when an issue item has been created on sharepoint.

 

I have 2 sharepoint list: Test HPBC Sunset v2 consisting of 4 columns: Title, Raised By, Private or Public, Description, Request Date, Department and Department:Manager. I have the created another list called Department Managers which consists of Department, Manager (email address) and Team Member (email addresses of team members).  

 

Ideally, whenever I create another item on HPVC Sunset v2, it would trigger an email to the Department Manager and Team Members of the Department that the user has inputted. For example, for the Test 2 item, the flow would trigger an email to the Finance Manager and Finance Team Members when the item is added. However, currently, whenever an item is created in HPVC Sunset v2, emails are generated to all team members and managers that are listed in Department Manager, instead of to repective team members and manager of the newly added item. 

 

Any help on this would be very much appreciated 🙂

3.2.jpg4.2.jpg

Anonymous
Not applicable

Hello @m4ngo5 ,

 

I am new with Flows.

 

Considering the same example with your List 1 and List 2 (Deparment managers and Item with department).

Suppose i want a condition that, when a new item is created in List 2 , the particular item ID in list 2 should be equal to item ID in list 1 (for newly created only). After that send an email when the condition satifies for the new item.

Could you help me to create MS flow out of this because what happens is in my flow is, it looks for all IDs not the new ID and send me multiple emails, as all IDs are same in List 1 and List 2 so the condition satifies for all items.

 

If possible please reply fast.

 

Thanks in advance.

 

Reagrds,

Sanket

 

 

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages