cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Teaners26
Helper I
Helper I

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.

Dewi86
Frequent Visitor

@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!

Dewi86
Frequent Visitor

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

Power Platform Connections Ep 15 | L. Baybutt | Thursday, 1 June 2023

Episode Fifteen of Power Platform Connections sees David Warner and Hugo Bernier talk to Microsoft MVP Lewis Baybutt aka Low Code Lewis, alongside the latest news and community blogs.   Use the hashtag #PowerPlatformConnects on social media for a chance to have your work featured on the show.        Action requested: Feel free to provide feedback on how we can make our community more inclusive and diverse.  This episode premiers live on our YouTube at 12pm PST on Thursday 1st June 2023.  Video series available at Power Platform Community YouTube channel.    Upcoming events:  European Power Platform conference – Jun. 20-22nd - Dublin Microsoft Power Platform Conference – Oct. 3-5th - Las Vegas  Join our Communities:  Power Apps Community Power Automate Community Power Virtual Agents Community Power Pages Community  If you’d like to hear from a specific community member in an upcoming recording and/or have specific questions for the Power Platform Connections team, please let us know. We will do our best to address all your requests or questions.  Action requested: Feel free to provide feedback on how we can make our community more inclusive and diverse.  This episode premiers live on our YouTube at 12pm PST on Thursday 1st June 2023.  Video series available at Power Platform Community YouTube channel.    Upcoming events:  European Power Platform conference – Jun. 20-22nd - Dublin Microsoft Power Platform Conference – Oct. 3-5th - Las Vegas  Join our Communities:  Power Apps Community Power Automate Community Power Virtual Agents Community Power Pages Community  If you’d like to hear from a specific community member in an upcoming recording and/or have specific questions for the Power Platform Connections team, please let us know. We will do our best to address all your requests or questions. 

May 2023 Community Newsletter and Upcoming Events

Welcome to our May 2023 Community Newsletter, where we'll be highlighting the latest news, releases, upcoming events, and the great work of our members inside the Biz Apps communities. If you're new to this LinkedIn group, be sure to subscribe here in the News & Announcements to stay up to date with the latest news from our ever-growing membership network who "changed the way they thought about code".         LATEST NEWS "Mondays at Microsoft" LIVE on LinkedIn - 8am PST - Monday 15th May  - Grab your Monday morning coffee and come join Principal Program Managers Heather Cook and Karuana Gatimu for the premiere episode of "Mondays at Microsoft"! This show will kick off the launch of the new Microsoft Community LinkedIn channel and cover a whole host of hot topics from across the #PowerPlatform, #ModernWork, #Dynamics365, #AI, and everything in-between. Just click the image below to register and come join the team LIVE on Monday 15th May 2023 at 8am PST. Hope to see you there!     Executive Keynote | Microsoft Customer Success Day CVP for Business Applications & Platform, Charles Lamanna, shares the latest #BusinessApplications product enhancements and updates to help customers achieve their business outcomes.         S01E13 Power Platform Connections - 12pm PST - Thursday 11th May Episode Thirteen of Power Platform Connections sees Hugo Bernier take a deep dive into the mind of co-host David Warner II, alongside the reviewing the great work of Dennis Goedegebuure, Keith Atherton, Michael Megel, Cat Schneider, and more. Click below to subscribe and get notified, with David and Hugo LIVE in the YouTube chat from 12pm PST. And use the hashtag #PowerPlatformConnects on social media for a chance to have your work featured on the show.         UPCOMING EVENTS   European Power Platform Conference - early bird ticket sale ends! The European Power Platform Conference early bird ticket sale ends on Friday 12th May 2023! #EPPC23 brings together the Microsoft Power Platform Communities for three days of unrivaled days in-person learning, connections and inspiration, featuring three inspirational keynotes, six expert full-day tutorials, and over eighty-five specialist sessions, with guest speakers including April Dunnam, Dona Sarkar, Ilya Fainberg, Janet Robb, Daniel Laskewitz, Rui Santos, Jens Christian Schrøder, Marco Rocca, and many more. Deep dive into the latest product advancements as you hear from some of the brightest minds in the #PowerApps space. Click here to book your ticket today and save!      DynamicMinds Conference - Slovenia - 22-24th May 2023 It's not long now until the DynamicsMinds Conference, which takes place in Slovenia on 22nd - 24th May, 2023 - where brilliant minds meet, mingle & share! This great Power Platform and Dynamics 365 Conference features a whole host of amazing speakers, including the likes of Georg Glantschnig, Dona Sarkar, Tommy Skaue, Monique Hayward, Aleksandar Totovic, Rachel Profitt, Aurélien CLERE, Ana Inés Urrutia de Souza, Luca Pellegrini, Bostjan Golob, Shannon Mullins, Elena Baeva, Ivan Ficko, Guro Faller, Vivian Voss, Andrew Bibby, Tricia Sinclair, Roger Gilchrist, Sara Lagerquist, Steve Mordue, and many more. Click here: DynamicsMinds Conference for more info on what is sure an amazing community conference covering all aspects of Power Platform and beyond.    Days of Knowledge Conference in Denmark - 1-2nd June 2023 Check out 'Days of Knowledge', a Directions 4 Partners conference on 1st-2nd June in Odense, Denmark, which focuses on educating employees, sharing knowledge and upgrading Business Central professionals. This fantastic two-day conference offers a combination of training sessions and workshops - all with Business Central and related products as the main topic. There's a great list of industry experts sharing their knowledge, including Iona V., Bert Verbeek, Liza Juhlin, Douglas Romão, Carolina Edvinsson, Kim Dalsgaard Christensen, Inga Sartauskaite, Peik Bech-Andersen, Shannon Mullins, James Crowter, Mona Borksted Nielsen, Renato Fajdiga, Vivian Voss, Sven Noomen, Paulien Buskens, Andri Már Helgason, Kayleen Hannigan, Freddy Kristiansen, Signe Agerbo, Luc van Vugt, and many more. If you want to meet industry experts, gain an advantage in the SMB-market, and acquire new knowledge about Microsoft Dynamics Business Central, click here Days of Knowledge Conference in Denmark to buy your ticket today!   COMMUNITY HIGHLIGHTS Check out our top Super and Community Users reaching new levels! These hardworking members are posting, answering questions, kudos, and providing top solutions in their communities.   Power Apps:  Super Users: @WarrenBelz, @LaurensM  @BCBuizer  Community Users:  @Amik@ @mmollet, @Cr1t    Power Automate:  Super Users: @Expiscornovus , @grantjenkins, @abm  Community Users: @Nived_Nambiar, @ManishSolanki    Power Virtual Agents:  Super Users: @Pstork1, @Expiscornovus  Community Users: @JoseA, @fernandosilva, @angerfire1213    Power Pages: Super Users: @ragavanrajan  Community Users: @Fubar, @Madhankumar_L,@gospa  LATEST COMMUNITY BLOG ARTICLES  Power Apps Community Blog  Power Automate Community Blog  Power Virtual Agents Community Blog  Power Pages Community Blog  Check out 'Using the Community' for more helpful tips and information:  Power Apps , Power Automate, Power Virtual Agents, Power Pages 

Announcing | Super Users - 2023 Season 1

Super Users – 2023 Season 1    We are excited to kick off the Power Users Super User Program for 2023 - Season 1.  The Power Platform Super Users have done an amazing job in keeping the Power Platform communities helpful, accurate and responsive. We would like to send these amazing folks a big THANK YOU for their efforts.      Super User Season 1 | Contributions July 1, 2022 – December 31, 2022  Super User Season 2 | Contributions January 1, 2023 – June 30, 2023    Curious what a Super User is? Super Users are especially active community members who are eager to help others with their community questions. There are 2 Super User seasons in a year, and we monitor the community for new potential Super Users at the end of each season. Super Users are recognized in the community with both a rank name and icon next to their username, and a seasonal badge on their profile.  Power Apps  Power Automate  Power Virtual Agents  Power Pages  Pstork1*  Pstork1*  Pstork1*  OliverRodrigues  BCBuizer  Expiscornovus*  Expiscornovus*  ragavanrajan  AhmedSalih  grantjenkins  renatoromao    Mira_Ghaly*  Mira_Ghaly*      Sundeep_Malik*  Sundeep_Malik*      SudeepGhatakNZ*  SudeepGhatakNZ*      StretchFredrik*  StretchFredrik*      365-Assist*  365-Assist*      cha_cha  ekarim2020      timl  Hardesh15      iAm_ManCat  annajhaveri      SebS  Rhiassuring      LaurensM  abm      TheRobRush  Ankesh_49      WiZey  lbendlin      Nogueira1306  Kaif_Siddique      victorcp  RobElliott      dpoggemann  srduval      SBax  CFernandes      Roverandom  schwibach      Akser  CraigStewart      PowerRanger  MichaelAnnis      subsguts  David_MA      EricRegnier  edgonzales      zmansuri  GeorgiosG      ChrisPiasecki  ryule      AmDev  fchopo      phipps0218  tom_riha      theapurva  takolota     Akash17  momlo     BCLS776  Shuvam-rpa     rampprakash  ScottShearer     Rusk  ChristianAbata     cchannon  Koen5     a33ik  Heartholme     AaronKnox  okeks      Matren  David_MA     Alex_10        Jeff_Thorpe        poweractivate        Ramole        DianaBirkelbach        DavidZoon        AJ_Z        PriyankaGeethik        BrianS        StalinPonnusamy        HamidBee        CNT        Anonymous_Hippo        Anchov        KeithAtherton        alaabitar        Tolu_Victor        KRider        sperry1625        IPC_ahaas      zuurg    rubin_boer   cwebb365   Dorrinda   G1124   Gabibalaban   Manan-Malhotra   jcfDaniel   WarrenBelz   Waegemma   drrickryp   GuidoPreite   metsshan    If an * is at the end of a user's name this means they are a Multi Super User, in more than one community. Please note this is not the final list, as we are pending a few acceptances.  Once they are received the list will be updated. 

Check out the new Power Platform Communities Front Door Experience!

We are excited to share the ‘Power Platform Communities Front Door’ experience with you!   Front Door brings together content from all the Power Platform communities into a single place for our community members, customers and low-code, no-code enthusiasts to learn, share and engage with peers, advocates, community program managers and our product team members. There are a host of features and new capabilities now available on Power Platform Communities Front Door to make content more discoverable for all power product community users which includes ForumsUser GroupsEventsCommunity highlightsCommunity by numbersLinks to all communities Users can see top discussions from across all the Power Platform communities and easily navigate to the latest or trending posts for further interaction. Additionally, they can filter to individual products as well.   Users can filter and browse the user group events from all power platform products with feature parity to existing community user group experience and added filtering capabilities.     Users can now explore user groups on the Power Platform Front Door landing page with capability to view all products in Power Platform.      Explore Power Platform Communities Front Door today. Visit Power Platform Community Front door to easily navigate to the different product communities, view a roll up of user groups, events and forums.

Microsoft Power Platform Conference | Registration Open | Oct. 3-5 2023

We are so excited to see you for the Microsoft Power Platform Conference in Las Vegas October 3-5 2023! But first, let's take a look back at some fun moments and the best community in tech from MPPC 2022 in Orlando, Florida.   Featuring guest speakers such as Charles Lamanna, Heather Cook, Julie Strauss, Nirav Shah, Ryan Cunningham, Sangya Singh, Stephen Siciliano, Hugo Bernier and many more.   Register today: https://www.powerplatformconf.com/   

Users online (3,842)