cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Gallery with checkboxes

So I'm super stuck. I have a gallery that contains checkboxes and is connected to SP list A. When a box is checked, I add the checked item to a collection:

If(
!IsBlank(
Filter(
'Project Time System',
Project = ThisItem.Project)), Collect(submitProjects,ThisItem), RemoveIf(checkedProjects,IsBlank(Checkbox3)))

 

When the user presses a submit button - the information from the collection is patched (new record created) into another SP list SP List B using:

ForAll(
Collection,
Patch(
SPList,
Defaults(SPList),
{
Columns and values....
}
         )
)

Everything works great, however - I'm stuck on once a record is added to SP List B, I would like to remove it from SP List A which will remove it from the gallery AND I want to remove it from the collection. This should be able to submit all checked items from the gallery at the same time. Any help is really appreciated - like I said - suuuuuppperrrr stuck =o)

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @Anonymous ,

Do you want to remove the record from your List A and submitProjects collection when you submit the record into your List B?

 

Based on the needs that you mentioned, I think the RemoveIf function could achieve your needs. I have made a test on my side, please consider take a try with the following workaround:

Set the OnSelect property of the "Submit" button to following:

ForAll(
       submitProjects,
       Patch(
             'B List',
              Defaults('B List'),
              {
                 ProjectColumn: submitProjects[@Project],
                 ...
              }
       )
);
Refresh('B List');
RemoveIf('A List', Project in 'B List'.ProjectColumn);  // Remove records from List A
RemoveIf(submitProjects, Project in 'B List'.ProjectColumn) // Remove records from colletion

Note: I assume that the Project column is a Primary column in your ListA. The Project column value from ListA would be saved into the ProjectColumn in ListB.

 

Please consider take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4

@Anonymous 

 

Where are you stuck? Are you able to remove it? You can remove it using Remove or RemoveIf

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-remove-removeif

 

Please give more details where you are stuck.

The Remove/RemoveIf (from the SharePoint list) could go in as part of your ForAll statement. Then recreate your collection after the ForAll has completed (if you gallery, that you are iterating through in the ForAll, is based on a local collection, I don't think you can modify that collect, by removing items, while in the ForAll loop).

v-xida-msft
Community Support
Community Support

Hi @Anonymous ,

Do you want to remove the record from your List A and submitProjects collection when you submit the record into your List B?

 

Based on the needs that you mentioned, I think the RemoveIf function could achieve your needs. I have made a test on my side, please consider take a try with the following workaround:

Set the OnSelect property of the "Submit" button to following:

ForAll(
       submitProjects,
       Patch(
             'B List',
              Defaults('B List'),
              {
                 ProjectColumn: submitProjects[@Project],
                 ...
              }
       )
);
Refresh('B List');
RemoveIf('A List', Project in 'B List'.ProjectColumn);  // Remove records from List A
RemoveIf(submitProjects, Project in 'B List'.ProjectColumn) // Remove records from colletion

Note: I assume that the Project column is a Primary column in your ListA. The Project column value from ListA would be saved into the ProjectColumn in ListB.

 

Please consider take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you for the responses everyone - I am going to mark this as the solution - the way I figured it out is a little different:

ForAll(
submitProjects,
Patch(
Project_Time_Master,
Defaults(Project_Time_Master),
{
Title: Title,
WeekStarting: WeekStarting,
Project: Project,
Task: Task,
Monday: Monday,
Tuesday: Tuesday,
Wednesday: Wednesday,
Thursday: Thursday,
Friday: Friday,
Saturday: Saturday,
Sunday: Sunday
}
)
);
Refresh('Project Time System');
ForAll(
submitProjects,
Remove('Project Time System', LookUp('Project Time System', ID = submitProjects[@ID])));
RemoveIf(submitProjects, Project in Project_Time_Master.Project)

 

If you see anything wrong with this or if it might fail as the list gets large (this is going to be for keeping track of time spent on projects for an entire department) please respond

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (3,938)