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

Create row items from a gallery using checkbox

Hello,

 

I have created a gallery with a checkbox for each items in the gallery list.

The idea is that the checkbox is used to select the items (it can be multiple!). 
Once selected there will be a button to duplicate the selected items. Also, I am using dataverse as my datasource.


Below is a snippet of my code,

ClearCollect(RecordsToCopy, DropColumns(BudgetMonthRecord.'Forecast Items',"_ownerid_value","createdby","modifiedby"));
Clear(NewRecords);

// collect new records into collections
Collect(NewRecords, RecordsToCopy);
Patch('Forecast Items', NewRecords);

Concurrent(
    Clear(NewRecords),
);

 

I wanted to create a collection for only the selected item. Would appreciate the help for this!
Thanks.

- Mia

3 REPLIES 3
Ashwin7104
Super User
Super User

Hey @anonymia25 ,

 

Please use below code to filter selected item from gallery. Please note that schema in collection and Dataverse table should be identical in terms of column names.

 

// collect selected records in gallery into collections
ClearCollect(collectionName, Filter(Gallery.AllItems,Checkbox.Value = true))

//Use Patch / Collect to create items
Patch('Forecast Items', NewRecords);

 

Hi @Ashwin7104 ,

I tried your solution, and this would be use in the onSelect property of the button, yes?
Unfortunately the item is not created and I am not sure what went wrong for this?

// collect selected records in gallery into collections
ClearCollect(RecordsToCopy, Filter(ForecastGallery.AllItems, Checkbox1.Value = true));
Clear(NewRecords);

// collect new records into collections
Collect(NewRecords, RecordsToCopy);

// create the new records in batch
Patch('Forecast Items', NewRecords);

 

Hi @anonymia25 ,

 

You can try below formula if it helps your requirement. 

 

ForAll(Filter(ForecastGallery.AllItems,Checkbox1.Value = true), Patch('Forecast Items'),Defaults('Forecast Items'),{ColumnName: ThisRecord.CollectionColumnName,.....})

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

If this post was helpful or you need more help please consider giving Thumbs Up and Tag me in your reply I'll be happy to help. If this post helped you solve your issue please click Accept as solution and provide Thumbs Up. This will help others find it more readily.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,098)