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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Items checked already,...
Power Apps
Unanswered

Items checked already, should appear unchecked for next event in gallery

(1) ShareShare
ReportReport
Posted on by 603

I have a powerapps gallery with SharePoint as the datasource.

 

I can create multiple events in calendar year. Below is the screenshot for the same. 

 

Iantaylor2050_0-1692074086028.png

 

Once the events has been created and if i click on Event 1 View button, it will redirect me to the events detail page. Screenshot included below. 

 

Iantaylor2050_1-1692074385347.png

 

If i click on Event 2 View button, it should redirect me to the above screen, however all the checkbox checked in the Event 1 screen should appear unchecked and i can select whatever items i need for Event 2. 

 

Similarly if i create Event 3, it should also have same behaviour. 

 

I also have submit button for each event. Once i click on submit button, it should patch the datasource with Status column as "Ready for Purchase". May i know how to achieve this?

 

I have included the code below for Event details page. Should i be creating separate collection for each events to track the checked and unchecked items?

 

App.OnStart

ClearCollect(
colListData1,
AddColumns(
Items,
"checkBoxVal",
false
)
)

Gallery Items Property 

If(
Len(SearchText_3.Text) = 0,
colListData1,
Filter(
colListData1,
SearchText_3.Text in 'Item Name' || SearchText_3.Text in Qty || SearchText_3.Text in 'Unit Price'
)
)

Gallery Checkbox1 OnCheck

UpdateIf(
colListData1,
ID = ThisItem.ID,
{checkBoxVal: true}
)

Gallery Checkbox1 OnUnCheck

UpdateIf(
colListData1,
ID = ThisItem.ID,
{checkBoxVal: false}
)

Gallery Checkbox1 default

ThisItem.checkBoxVal

Categories:
I have the same question (0)
  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    Looks like you're dealing with a situation where you have multiple events, and for each event, you have a set of items that can be checked or unchecked independently. Your current setup seems to be using one collection to handle all the events, but since you want different behavior for each event, you need to manage these states separately.

     

    Create separate collections for each event

    You can use a different collection for each event, and when you navigate to an event detail page, you can clear the collection and repopulate it with the required details for that specific event.

     

    Patch the selected items with the required status on submit

    When the submit button is clicked, you can use the Patch function to update the SharePoint list with the required status.

    Below are the updated formula examples:

     

    In App.OnStart

    Instead of populating the collection at the start, you can do this when you navigate to an event. This way, you can ensure that every time you view an event, the checkboxes start unchecked.

     

    On View Button Click for Event

    When you click the View button for an event, you can execute the following

    (using OnSelect property of your View Button😞

     

    ClearCollect(
     colListData1,
     AddColumns(
     Filter(YourSharePointList, EventID = selectedEventID),
     "checkBoxVal",
     false
     )
    )
    Navigate(EventDetailScreen, ScreenTransition.None)
    

     

    Replace YourSharePointList with your SharePoint data source and selectedEventID with the ID for the event you're viewing.

     

    Gallery Items Property

    You have this part correct. No change is required here.

     

    Gallery Checkbox OnCheck and OnUnCheck

    The formulas you have for these functions should be appropriate as well.

     

    On Submit Button Click

    You can use the following to update the SharePoint list

    (OnSelect of your Submit Button):

     

    ClearCollect(
     colBaseRecs,
     DropColumns(
     Filter(colListData1, checkBoxVal = true),
     "checkBoxVal"
     )
    )
    
    ClearCollect(
     colChangeRecs,
     ForAll(
     colBaseRecs,
     {Status: "Ready for Purchase"}
     )
    )
    
    Patch(
     YourSharePointList,
     colBaseRecs,
     colChangeRecs
    )
    

     

    Replace YourSharePointList with your SharePoint data source.

    With these modifications, every time you navigate to an event detail screen, the items should start unchecked, and when you submit, the selected items will be patched with the required status.

     

    See if this helps @Iantaylor2050 

  • Iantaylor2050 Profile Picture
    603 on at

    Hi @poweractivate  @WarrenBelz 

     

    I have made below code changes, however i notice that checked items values are not preserved properly for each events. i.e. If i go to a event and check 4 items out of 5 and submit, if i view back the same event again, 4 checked items should show checked, but it shows all items unchecked. May i know why? Below is the code

     

    Gallery Items property

    Filter(
    colListData1,
    (Len(SearchText_3.Text) = 0 || (SearchText_3.Text in 'Item Name' || SearchText_3.Text in Qty || SearchText_3.Text in 'Unit Price')) && (ComboBox9.Selected.Value = "All" || (ComboBox9.Selected.Value = "Checked Items" && checkBoxVal && EventID = currentevent.ID) || (ComboBox9.Selected.Value = "Unchecked Items" && (!checkBoxVal)))
    )

    Gallery CheckBox OnCheck

    UpdateIf(
    colListData1,
    ID = ThisItem.ID,
    {checkBoxVal: true,EventID:currentevent.ID}
    )

     

    Gallery CheckBox OnCheck

    UpdateIf(
    colListData1,
    ID = ThisItem.ID,
    {checkBoxVal: false,EventID:Blank()}
    )

     

    Gallery Checkbox Default

    ThisItem.checkBoxVal&&ThisItem.EventID=currentevent.ID

     

    Gallery SelectAll Checkbox at the top OnCheck

    With(
    {
    _temp: colListData1
    },
    ForAll(_temp,
    Patch(colListData1,
    ThisRecord,
    {
    checkBoxVal:true
    }
    )
    )
    )

     

    Gallery SelectAll Checkbox at the top OnUnCheck

    With(
    {
    _temp: colListData1
    },
    ForAll(_temp,
    Patch(colListData1,
    ThisRecord,
    {
    checkBoxVal:false
    }
    )
    )
    )

     

    Gallery SelectAll Checkbox at the top default

    false

     

    Gallery Submit Button

    ForAll(
    Gallery1_3.AllItems,
    Patch(
    colListData1,
    ThisRecord,
    {
    Start_Value: Value(TextInput8.Text),
    Incremental_Value: Value(ComboBox6.Selected.Value),
    checkBoxVal: Checkbox1.Value,
    EventID: currentevent.ID
    }
    )
    );

     

    Collection at App OnStart

    I cannot create multiple collection for every event because user can create n number of events, so trying to use single collection for all events. I tried creating like ClearCollect(colListData&currentevent.ID,Items) but it throws error

    ClearCollect(
    colListData1,
    AddColumns(Filter(
    Items,Item_Status="Ready for Purchase"),
    "checkBoxVal",
    false
    )
    )

     

    Iantaylor2050_0-1692191428170.png

     

    Iantaylor2050_1-1692191452388.png

     

     

  • Iantaylor2050 Profile Picture
    603 on at

    Hi All,

     

    Can please assist me on the above query please?

  • Iantaylor2050 Profile Picture
    603 on at

    Hi @WarrenBelz 

     

    Can please assist me on the above query? Thanks. 

  • Iantaylor2050 Profile Picture
    603 on at

    Hi @WarrenBelz 

     

    Could you please help me out on the above query?

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 483

#2
WarrenBelz Profile Picture

WarrenBelz 399 Most Valuable Professional

#3
11manish Profile Picture

11manish 327

Last 30 days Overall leaderboard