cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jharville1
Helper IV
Helper IV

Add items selected from combo-box (lookup) to collection, send email to certain user(s) based on selection

I have a combo-box called 'reviewComboBox' (that contains items pulled from a Lookup column) inside my application. Some of the items are: January, February, March, April, May ... and so on.

 

My combo-box allows for multiple selections. I would like for: when the user selects multiple items and submits the form once they have made all their changes (ex: selecting what items they'd like, and de-selecting what they would not like if they change their mind), the items selected in that combo-box will be added together to a collection in the form of a table. Here's a visual of the collection I'd like if the 3 items: 'January' , 'February' , and 'March' are selected in the combo-box -->

 

jharville1_1-1606142702340.png

I have tried the following code (as well as ClearCollect(colReviewItems, yourComboBox.SelectedItems) ) in both the "OnSelect" and "OnChange" properties (in the 'Advanced Properties') section of my combo-box, but nothing is collected at all... Does anybody see any issue with my code?

 

jharville1_2-1606142774145.png

-------------------------------------

jharville1_3-1606142822366.png

I have been told from other users on this forum that I wouldn't need to create a collection, as I can rather simply reference yourComboBox.SelectedItems in any place of my app. However, the reason why I am trying to collect the items from the combo-box is because I'm building an 'Approvals' application that creates an approval for each of the items selected in the combo-box. The collection will count each item stored in it and ultimately uses a patch statement to create the approvals. I already have the 'Approvals' app built so that it creates one approval for the entire form, but need to tweak it to create an approval for each item selected.

 

The application: consists of one form with an input text field where the user inserts their name, and a combo-box section. I want each item selection within the combo-box to route the form to a specific person, since the look-up that my combo-box is using is pulling from a separate list ('review materials') that has 2 columns. One for the item (ex: January), and the second column for an email address. So in one row, there is a corresponding Item and Email Address.

 

11.23 forum pic.png

 

ex: January emails (routes) the form to 123@gmail.com for approval of that 1 item (January), while February emails the form to xyz@gmail.com for approval of that 1 item (February). If both January and February are selected, both of the email recipients stated will be sent an email for approval of those 2 items (January and February).

 

My goal is to add those items selected to the collection, write code to have a count of how many items are in that collection, and then create sub-approvals for each item with a patch. But as of now, I just need help adding those selected combo-box items to a collection, where I can later count how many are in the collection and send out emails based on what was selected.

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@jharville1 

So the logic it there...  It all starts from your Combobox.  Since you have the Items property set to 'review materials', the selected items will have the full record of the item from the list.

So, if January and February are selected, then you will have a variable called mySelectedItems (using the Formula I provided before), and that variable will have the following structure:

[
   {Title: "January",  'Routed To':"123@gmail.com"},
   {Title: "February", 'Routed To':"xyz@gmail.com"}
]

 

Now, in your OnSuccess, you would have the formula below and it will execute the SendEmailV2 on all of the records above:

 

ForAll(myItemsSelected,

    Office365Outlook.SendEmailV2(
        'Routed To',
        subject,
        body
     )
)

Now, the above will send an individual email to 123@gmail.com and xyz@gmail.com.  You can craft your subject/body as needed:

 

If you want to sent 1 email to both selected with information about both selected, then you can do the following:

Office365Outlook.SendEmailV2(
    Concat(myItemsSelected, 'Routed To' & ";"),
    "Approvals",
    "Approvals are needed for " & Concat(myItemsSelected, Title & ", ")
)

This would send 1 email to 123@gmail.com; xyz@gmail.com (notice they are semicolon separated) and it will have a body that shows the two selected months (from Title) in it.

 

Am I close to what you are looking for?

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

11 REPLIES 11
RandyHayes
Super User
Super User

@jharville1 

So, it is true that your SelectedItems property is already a table/collection.  Creating another one from it is a bit redundant.  Also, consider that a collection is a bit of excessive overhead for what you are trying as, if you truly wanted to "snapshot" the selected items, you could simply store it in a variable - 

ex.  Set(myItemsSelected: yourCombobox.SelectedItems)

 

If your items property of the Combobox already includes the full record from your Review Materials list, then you have pretty much everything you need.

 

Now, I am not sure exactly what you mean by "routing the form".  Does this mean that you have a PowerAutomate flow that is going to take over and do some routing, or that you want then for your App to send out emails?

 

If you are going with the "snapshot" approach, then consider the following:

1) Prior to your SubmitForm, put in a Set(myItemsSelected: yourCombobox.SelectedItems) (obviously replacing the name of the combobox with the proper name of your control).

 

2) In the OnSuccess action of your Form, conduct the following:

   ForAll(myItemsSelected,

      Pacth(aList, aRecord, {someValues})
   )

 

Of course the specifics of #2 above are going to be based on my question of what you mean by "routing the form".

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
jharville1
Helper IV
Helper IV

 

 

@RandyHayes Thank you for the response Randy. When I mentioned "routing" the form, I meant emailing the users specified in the same row (in the SharePoint List) as the item name. Ex: the selection of 'January' emails 123@gmail.com that they have a form that needs to be approved. I was thinking of using the Office365Outlook.SendEmail() function to send the email to the corresponding email address in the same row, but still need to plan how I'd set up the code so that it would only send to those emails specified.

 

jharville1_0-1606147804004.png

 

RandyHayes
Super User
Super User

@jharville1 

You had mentioned Patching something before, so I am not sure where that fits in now.

But, if you are sending then from your app, again follow as I outlined before and then in your OnSuccess action, use the following:

ForAll(myItemsSelected,

    Office365Outlook.SendEmailV2(
        'Routed To',
        subject,
        body
     )
)

 

The above is based on the assumption that your original Combobox has an Items property of 'review materials'.

In this case, the 'Routed To' information will all be in the myItemsSelected variable that you are setting in the formula before you do a SubmitForm.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayesI really do appreciate your help and the response. But for the above code, how would I be able to differentiate who I send the email to based on what item is selected, instead of sending all selected items to the same group of people?

 

ex: January emails (routes) the form to 123@gmail.com for approval of that 1 item (January), while February emails the form to xyz@gmail.com for approval of that 1 item (February). If both January and February are selected, both of the email recipients stated will be sent an email for approval of those 2 items (January and February).

RandyHayes
Super User
Super User

@jharville1 

So the logic it there...  It all starts from your Combobox.  Since you have the Items property set to 'review materials', the selected items will have the full record of the item from the list.

So, if January and February are selected, then you will have a variable called mySelectedItems (using the Formula I provided before), and that variable will have the following structure:

[
   {Title: "January",  'Routed To':"123@gmail.com"},
   {Title: "February", 'Routed To':"xyz@gmail.com"}
]

 

Now, in your OnSuccess, you would have the formula below and it will execute the SendEmailV2 on all of the records above:

 

ForAll(myItemsSelected,

    Office365Outlook.SendEmailV2(
        'Routed To',
        subject,
        body
     )
)

Now, the above will send an individual email to 123@gmail.com and xyz@gmail.com.  You can craft your subject/body as needed:

 

If you want to sent 1 email to both selected with information about both selected, then you can do the following:

Office365Outlook.SendEmailV2(
    Concat(myItemsSelected, 'Routed To' & ";"),
    "Approvals",
    "Approvals are needed for " & Concat(myItemsSelected, Title & ", ")
)

This would send 1 email to 123@gmail.com; xyz@gmail.com (notice they are semicolon separated) and it will have a body that shows the two selected months (from Title) in it.

 

Am I close to what you are looking for?

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayesThis is exactly what I'm looking for and what I was having troubles with. Thank you so much, I really do appreciate your time and help!

RandyHayes
Super User
Super User

@jharville1 

Glad that hit the spot!!

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes 

 

I'm sorry but I have one last question on something I failed to realize. I actually checked the 'Items' property of my combo-box, and it isn't 'review materials' ... it is Choices([@'test list'].reviewItem). reviewItem is the name of the column in my main list, which is called test list. This was the lookup I mentioned earlier. I have a list called 'review materials' that holds all of my items (selections) that I want in my combo-box , but the combo-box references a lookup column in my main list ('test list').

 

Would I be able to implement the same code you mentioned if this is the case to send the email to specific users based on the full record of the item from the original list? I'm not sure if I will be able to do so since there is only one lookup column in my main list ('test list'), rather than having the full record of the item from the original list ('review materials').

 

Thank you so much, I really do apologize for not catching this minor detail earlier.

RandyHayes
Super User
Super User

@jharville1 

That should be fine.  Just change the Combobox Items property to 'review materials'

This is correct as typically (for lookups) you would reference the actual source of the lookup and not the choices.  This will give you the full records.

So, set the Items to 'review materials' and your value to display as Title.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Tuesday Tip: Community User Groups

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: Community User Groups and YOU Being part of, starting, or leading a User Group can have many great benefits for our community members who want to learn, share, and connect with others who are interested in the Microsoft Power Platform and the low-code revolution.   When you are part of a User Group, you discover amazing connections, learn incredible things, and build your skills. Some User Groups work in the virtual space, but many meet in physical locations, meaning you have several options when it comes to building community with people who are learning and growing together!   Some of the benefits of our Community User Groups are: Network with like-minded peers and product experts, and get in front of potential employers and clients.Learn from industry experts and influencers and make your own solutions more successful.Access exclusive community space, resources, tools, and support from Microsoft.Collaborate on projects, share best practices, and empower each other. These are just a few of the reasons why our community members love their User Groups. Don't wait. Get involved with (or maybe even start) a User Group today--just follow the tips below to get started.For current or new User Group leaders, all the information you need is here: User Group Leader Get Started GuideOnce you've kicked off your User Group, find the resources you need:  Community User Group ExperienceHave questions about our Community User Groups? Let us know! We are here to help you!

Super User of the Month | Ahmed Salih

We're thrilled to announce that Ahmed Salih is our Super User of the Month for April 2024. Ahmed has been one of our most active Super Users this year--in fact, he kicked off the year in our Community with this great video reminder of why being a Super User has been so important to him!   Ahmed is the Senior Power Platform Architect at Saint Jude's Children's Research Hospital in Memphis. He's been a Super User for two seasons and is also a Microsoft MVP! He's celebrating his 3rd year being active in the Community--and he's received more than 500 kudos while authoring nearly 300 solutions. Ahmed's contributions to the Super User in Training program has been invaluable, with his most recent session with SUIT highlighting an incredible amount of best practices and tips that have helped him achieve his success.   Ahmed's infectious enthusiasm and boundless energy are a key reason why so many Community members appreciate how he brings his personality--and expertise--to every interaction. With all the solutions he provides, his willingness to help the Community learn more about Power Platform, and his sheer joy in life, we are pleased to celebrate Ahmed and all his contributions! You can find him in the Community and on LinkedIn. Congratulations, Ahmed--thank you for being a SUPER user!  

Tuesday Tip: Getting Started with Private Messages & Macros

Welcome to TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   This Week's Tip: Private Messaging & Macros in Power Apps Community   Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member!   Our Knowledge Base article about private messaging and macros is the best place to find out more. Check it out today and discover some key tips and tricks when it comes to messages and macros:   Private Messaging: Learn how to enable private messages in your community profile and ensure you’re connected with other community membersMacros Explained: Discover the convenience of macros—prewritten text snippets that save time when posting in forums or sending private messagesCreating Macros: Follow simple steps to create your own macros for efficient communication within the Power Apps CommunityUsage Guide: Understand how to apply macros in posts and private messages, enhancing your interaction with the Community For detailed instructions and more information, visit the full page in your community today:Power Apps: Enabling Private Messaging & How to Use Macros (Power Apps)Power Automate: Enabling Private Messaging & How to Use Macros (Power Automate)  Copilot Studio: Enabling Private Messaging &How to Use Macros (Copilot Studio) Power Pages: Enabling Private Messaging & How to Use Macros (Power Pages)

April 4th Copilot Studio Coffee Chat | Recording Now Available

Did you miss the Copilot Studio Coffee Chat on April 4th? This exciting and informative session with Dewain Robinson and Gary Pretty is now available to watch in our Community Galleries!   This AMA discussed how Copilot Studio is using the conversational AI-powered technology to aid and assist in the building of chatbots. Dewain is a Principal Program Manager with Copilot Studio. Gary is a Principal Program Manager with Copilot Studio and Conversational AI. Both of them had great insights to share with the community and answered some very interesting questions!     As part of our ongoing Coffee Chat AMA series, this engaging session gives the Community the unique opportunity to learn more about the latest Power Platform Copilot plans, where we’ll focus, and gain insight into upcoming features. We’re looking forward to hearing from the community at the next AMA, so hang on to your questions!   Watch the recording in the Gallery today: April 4th Copilot Studio Coffee Chat AMA

Tuesday Tip: Subscriptions & Notifications

TUESDAY TIPS are our way of communicating helpful things we've learned or shared that have helped members of the Community. Whether you're just getting started or you're a seasoned pro, Tuesday Tips will help you know where to go, what to look for, and navigate your way through the ever-growing--and ever-changing--world of the Power Platform Community! We cover basics about the Community, provide a few "insider tips" to make your experience even better, and share best practices gleaned from our most active community members and Super Users.   With so many new Community members joining us each week, we'll also review a few of our "best practices" so you know just "how" the Community works, so make sure to watch the News & Announcements each week for the latest and greatest Tuesday Tips!   This Week: All About Subscriptions & Notifications We don't want you to a miss a thing in the Community! The best way to make sure you know what's going on in the News & Announcements, to blogs you follow, or forums and galleries you're interested in is to subscribe! These subscriptions ensure you receive automated messages about the most recent posts and replies. Even better, there are multiple ways you can subscribe to content and boards in the community! (Please note: if you have created an AAD (Azure Active Directory) account you won't be able to receive e-mail notifications.)   Subscribing to a Category  When you're looking at the entire category, select from the Options drop down and choose Subscribe.     You can then choose to Subscribe to all of the boards or select only the boards you want to receive notifications. When you're satisfied with your choices, click Save.   Subscribing to a Topic You can also subscribe to a single topic by clicking Subscribe from the Options drop down menu, while you are viewing the topic or in the General board overview, respectively.     Subscribing to a Label Find the labels at the bottom left of a post.From a particular post with a label, click on the label to filter by that label. This opens a window containing a list of posts with the label you have selected. Click Subscribe.           Note: You can only subscribe to a label at the board level. If you subscribe to a label named 'Copilot' at board #1, it will not automatically subscribe you to an identically named label at board #2. You will have to subscribe twice, once at each board.   Bookmarks Just like you can subscribe to topics and categories, you can also bookmark topics and boards from the same menus! Simply go to the Topic Options drop down menu to bookmark a topic or the Options drop down to bookmark a board. The difference between subscribing and bookmarking is that subscriptions provide you with notifications, whereas bookmarks provide you a static way of easily accessing your favorite boards from the My subscriptions area.   Managing & Viewing Your Subscriptions & Bookmarks To manage your subscriptions, click on your avatar and select My subscriptions from the drop-down menu.     From the Subscriptions & Notifications tab, you can manage your subscriptions, including your e-mail subscription options, your bookmarks, your notification settings, and your email notification format.     You can see a list of all your subscriptions and bookmarks and choose which ones to delete, either individually or in bulk, by checking multiple boxes.     A Note on Following Friends on Mobile Adding someone as a friend or selecting Follow in the mobile view does not allow you to subscribe to their activity feed. You will merely be able to see your friends’ biography, other personal information, or online status, and send messages more quickly by choosing who to send the message to from a list, as opposed to having to search by username.

Top Solution Authors
Top Kudoed Authors
Users online (4,674)