web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Clear multiple collect...
Power Apps
Answered

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

(0) ShareShare
ReportReport
Posted on by 160

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! 

Categories:
I have the same question (0)
  • Verified answer
    BCLS776 Profile Picture
    8,994 Moderator on at

    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

     

     

  • GoGorilla Profile Picture
    160 on at

    Thank you!!

  • GoGorilla Profile Picture
    160 on at

    @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

     

     

  • BCLS776 Profile Picture
    8,994 Moderator on at

    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

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard