cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ricteel
Regular Visitor

A multi-select field inside of a collection: how to patch the data back to a list?

Hello. I have built a PowerApp canvas app that allows the user to easily enter near-duplicate data records and store them temporarily in a shopping cart (BadgeRequests).  The shopping cart is really an in-memory collection of the data. When the user has entered all of the items that she needs, she will click the "Submit All" button to save the shopping cart to the SharePoint list. Additionally, each badge request could have multiple clearances chosen.  Here is a screenshot to illustrate:

ScreenShot01.JPG

That is the MyClearances field which is a LOOKUP on the Clearances list. It is setup to allow the user to select one or more items.

 

Like I said this data is stored in a collection so that the user can submit them all-at-once. Or they can choose to cancel and none of the records will get patched.  Here is a screenshot of the collection.

ScreenShot04.JPG

 

I have been able to figure out how to patch most of the fields back into the list.  But, I have hit a road-block on this multi-select field, MyClearances. I am having difficulty trying to get that data patched back to the list.  Here is the code that I am using. These are the simple fields for me to patch.  However, I cannot figure out how to patch the multiselect field.

ForAll(collect_NonTypBadg,
    Patch(NonTypicalBadges, 
        Defaults(NonTypicalBadges), 
        {BadgeType:collect_NonTypBadg[@BadgeType], 
            BusinessReason:collect_NonTypBadg[@BusinessReason], 
            Comments:collect_NonTypBadg[@Comments],
            Company:collect_NonTypBadg[@Company], 
            DateNeeded:collect_NonTypBadg[@DateNeeded],
            FirstName:collect_NonTypBadg[@FirstName], 
            LastName:collect_NonTypBadg[@LastName], 
            DateExpires:collect_NonTypBadg[@DateExpires],
            PictureNeeded:collect_NonTypBadg[@PictureNeeded],
            RequestStatus:collect_NonTypBadg[@RequestStatus],
            SupervisorAE:collect_NonTypBadg[@SupervisorAE],
            Title:Concatenate("New badge request for ",collect_NonTypBadg[@FirstName]," ",collect_NonTypBadg[@LastName]),
            PicURL_text:collect_NonTypBadg[@PicURL_text],
            PrimaryLocation:collect_NonTypBadg[@PrimaryLocation]
        }
    )
);

 

I have tried a loop inside of the main forall() loop, but it keeps giving me errors on the syntax.  Is there a good way to do this?

Thanks in advance.  --Rick

1 ACCEPTED SOLUTION

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @ricteel ,

 

I did a simple demo for you.

vxiaochenmsft_0-1631238828603.png

vxiaochenmsft_1-1631238844379.png

Add a button control and set its onselect property to:

 

ClearCollect(Col,{ColTitle:1,ColLookup:Table({Id:1,Value:"A"},{Id:3,Value:"C"})},{ColTitle:2,ColLookup:Table({Id:2,Value:"B"},{Id:5,Value:"E"})})

 

vxiaochenmsft_2-1631238877636.png

vxiaochenmsft_3-1631238886331.png

vxiaochenmsft_4-1631238893796.png

 

Add another button control and set its onselect property to:

 

ForAll(Col,Patch(LIST167,Defaults(LIST167),{Title:ColTitle,My_Lookup_to_LIST166:ColLookup}))

 

 

The result is as follows:

vxiaochenmsft_5-1631238925309.png

 

Best Regards,

Wearsky

 

 

 

 

 

 

 

View solution in original post

4 REPLIES 4
zmansuri
Super User
Super User

Thanks @zmansuri   That looks like a really good resource!  I have bookmarked it for future reference and I am sure I will visit it often.

 

However, the closest example I could find in that blog was to patch multiple choices directly from a combo-box.  That is a pretty easy task and I have done that often. 

Patch(
    'Painting Jobs',
    LookUp('Painting Jobs', ID=1),
    {
        ColorsChoice: ComboBox_Colors.SelectedItems
    }
)

My issue is a little different in that I am patching from a collection that contains a multi-selection field.

 

v-xiaochen-msft
Community Support
Community Support

Hi @ricteel ,

 

I did a simple demo for you.

vxiaochenmsft_0-1631238828603.png

vxiaochenmsft_1-1631238844379.png

Add a button control and set its onselect property to:

 

ClearCollect(Col,{ColTitle:1,ColLookup:Table({Id:1,Value:"A"},{Id:3,Value:"C"})},{ColTitle:2,ColLookup:Table({Id:2,Value:"B"},{Id:5,Value:"E"})})

 

vxiaochenmsft_2-1631238877636.png

vxiaochenmsft_3-1631238886331.png

vxiaochenmsft_4-1631238893796.png

 

Add another button control and set its onselect property to:

 

ForAll(Col,Patch(LIST167,Defaults(LIST167),{Title:ColTitle,My_Lookup_to_LIST166:ColLookup}))

 

 

The result is as follows:

vxiaochenmsft_5-1631238925309.png

 

Best Regards,

Wearsky

 

 

 

 

 

 

 

View solution in original post

Hello Wearsky,  This is it!  Thank you so much for taking the time to build out a sample for me.  I really appreciate it... that fits perfectly to my style of learning (poor reading skills and easily distracted) 🙂

This is exactly what i needed.  Thanks again.  --Rick

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,676)