cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rob_CTL
Helper V
Helper V

SharePoint Lists - Using a list as a lookup to populate field on another lsit

Hi,

 

I am trying to covert a SP2013 Workflow to Flow and it's proving a bit of a challenge.  So the concept is that an email is sent to a shared mailbox.  Flow then picks up this email and captures the sender, subject and body and this injected this into a SharePoint list called "Tickets".  Then my trusty SP2013 workflow would then look at the sender field and using "Category lookup" it would lookup the senders email address on another list called "Categories", this list has a number of email addresses and each is associated to a category.  The workflow would match the email address and category associated and populate the category field on the Ticket list.

 

Ticket list structure:

 

flow-lists1.png

 

Categories List structure

 

flow-lists2.png

 

The issue I have is that when I try to add a condition, Flow wraps it up in a "Apply to each" control which means it goes through each email address rather than just looking for a match and doing the update.

 

Flow:

 

flow-lists3.png

flow-lists4.png

value = body('Get_the_Categories_List_Items')?['value']

Email Ad... = items('Apply_to_each_-_Set_Categories')?['Title']

Outputs = outputs('Set_Email_subject_to_lowercase')

 

Is there any way to get Flow to simply look for an email address match then get the category?

 

Thanks in advance

Rob

1 ACCEPTED SOLUTION

Accepted Solutions
SCTdan
Continued Contributor
Continued Contributor

I'd suggesting using an oData filter in your sharepoint lookup.  

 

In your 'Get the categories list item' action, click show advanced options.  You'll want to see if the incoming email sender matches the email in the categories list.  That'll be something like EmailAddress eq 'email'  , where email is the value you want to lookup, and EmailAddress is the sharepoint column.  Single quote around your search query.  Make sure that's the proper column name, it may be Email0x200Address or something.  You can see the correct name in the URL if you're in the column settings.  

 

That should return you only one item, assuming the address is in the list and there aren't duplicates.

 

After this I like to throw in a condition to handle if it doesn't return anything.  You can use the empty() expression to check if it returned anything or not.  Then, to reference the item, use an array index instead so it doesn't go into a loop.  body('get_the_categories_list_item')[0]?['Category'] will give you the value for Category from the first result.  

 

Let me know if that makes sense, I can find an example to post.

 

 

View solution in original post

3 REPLIES 3
SCTdan
Continued Contributor
Continued Contributor

I'd suggesting using an oData filter in your sharepoint lookup.  

 

In your 'Get the categories list item' action, click show advanced options.  You'll want to see if the incoming email sender matches the email in the categories list.  That'll be something like EmailAddress eq 'email'  , where email is the value you want to lookup, and EmailAddress is the sharepoint column.  Single quote around your search query.  Make sure that's the proper column name, it may be Email0x200Address or something.  You can see the correct name in the URL if you're in the column settings.  

 

That should return you only one item, assuming the address is in the list and there aren't duplicates.

 

After this I like to throw in a condition to handle if it doesn't return anything.  You can use the empty() expression to check if it returned anything or not.  Then, to reference the item, use an array index instead so it doesn't go into a loop.  body('get_the_categories_list_item')[0]?['Category'] will give you the value for Category from the first result.  

 

Let me know if that makes sense, I can find an example to post.

 

 

chsanche
Community Support
Community Support

Hi @Rob_CTL 

 

The reason why Flow is wrapping the condition inside an Apply to each is because of the actions that you are using above, if you retrieve a list from SharePoint, then Flow will recognize this and insert an Apply to each. You are using Get Items and this retrieves a list.

 

Best Regards

--

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions help users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

If this post helps you give a :thumbs_up: and if it solved your issue consider Accept it as the solution

Thanks @SCTdan nice solution.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022- Season 2 has kicked off!

Users online (3,356)