cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GoGorilla
Helper III
Helper III

Clear multiple collections with one function and also collect multiple collections with one function

In the OnVisible property of a form, if form mode is NOT New then collect multiple collections with one Collect function, but if form mode IS new use Clear function to clear multiple collections with one function.  I know that my syntax is off but I am not finding a solution out there.  The following is my function:

If(
    frmEditDisplayAll.Mode <> New,
    Collect(
        (colMgrPMCorpContract,
        Gallery1.Selected.MgrPMCorpContractEmp)
      &&
        (colMgrPMContractOnly,
         Gallery1.Selected.MgrPMContractEmp) 
      &&
         (colMgrPMOfficersStaff,
         Gallery1.Selected.MgrPMOfficersStaff)
         ),

Clear(
    (colMgrPMCorpContract) && (colMgrPMContractOnly) && (colMgrPMOfficersStaff)
    )
)

 Thank you in advance for your assistance! 

1 ACCEPTED SOLUTION

Accepted Solutions
BCLS776
Super User
Super User

This syntax should work better:

If(
    frmEditDisplayAll.Mode <> New,
    Collect
        (colMgrPMCorpContract,
        Gallery1.Selected.MgrPMCorpContractEmp);
    Collect
        (colMgrPMContractOnly,
         Gallery1.Selected.MgrPMContractEmp);
    Collect
         (colMgrPMOfficersStaff,
         Gallery1.Selected.MgrPMOfficersStaff)
         );,

Clear(colMgrPMCorpContract);
Clear(colMgrPMContractOnly);
Clear(colMgrPMOfficersStaff);
)

Bryan

 

 

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

View solution in original post

4 REPLIES 4
BCLS776
Super User
Super User

This syntax should work better:

If(
    frmEditDisplayAll.Mode <> New,
    Collect
        (colMgrPMCorpContract,
        Gallery1.Selected.MgrPMCorpContractEmp);
    Collect
        (colMgrPMContractOnly,
         Gallery1.Selected.MgrPMContractEmp);
    Collect
         (colMgrPMOfficersStaff,
         Gallery1.Selected.MgrPMOfficersStaff)
         );,

Clear(colMgrPMCorpContract);
Clear(colMgrPMContractOnly);
Clear(colMgrPMOfficersStaff);
)

Bryan

 

 

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Thank you!!

GoGorilla
Helper III
Helper III

@BCLS776  Hi, there.  I marked you answer as a solution which it does work except I just now thought about testing it when I uncheck an item.  It works properly in the data card but it is just appending the collection with the items that remain checked or the newly checked items.  This, of course, is pushing the whole collection with the items appended to the SharePoint list.  I have OnUncheck property of the check box populated as follows:

Remove(colMgrPMCorpContract,ThisItem)

 

And the OnCheck property of the check box is as follows:

Collect(colMgrPMCorpContract,ThisItem)

 

I need the function in the OnVisible property of the form to hold the values if necessary, but I also need the ability to remove items from the collection to update the SharePoint List and to not continue to append to the collection if no changes have been made to that field.

GoGorilla_0-1637605588340.png

 

 

Hmm, I don't see anything about working with a check box in last weeks' conversation, so I am at a loss as to how to help with that functionality. Check boxes have two separate, useful behavior properties (OnCheck & OnUncheck) that are great for performing actions as a user clicks on that control. Perhaps using one or both of those properties to modify your collection is your solution?

 

ClearCollect() does a Clear() followed by a Collect() so the effect is to empty the collection completely of all records before collecting new ones. I am not sure if that fits with your app logic, but if you tell us more about how your app works then we might be able to guide you better.

 

It may also work better to post this question separately and include a link back to this thread.

 

Bryan

 

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Helpful resources

Announcements
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.

Top Kudoed Authors
Users online (3,429)