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 / confusion over a colle...
Power Apps
Unanswered

confusion over a collection not getting cleared because of one field

(0) ShareShare
ReportReport
Posted on by 59

Only one field in my Power App is causing problem when updating : the "person" field.

 

I have a collection that keeps track of the updates, and when an update is sent with a "save" button, the update collection is cleared.

 

If I add a "person" to an entry, and hit "save", the update collection does not get cleared.

 

Any idea ?

 

Here's what I use for person :

 

- combo box

- OnChange = Select(btnUpdate) - like my other fields

- Items = Choices(Tasks.Auteur) - like my "Priority" field, which is Choices(Tasks.Priority)

- DefautSelectedItems = ThisItem.Auteur

 

 

The btnUpdate OnSelect code :

 

If(
    IsBlank(
        LookUp(
            colGridUpdates,
            ID = ThisItem.ID
        )
    ),
    Collect(
        colGridUpdates, // c ici qu'on crée la collection
        ThisItem
    )
);

UpdateIf(
    colGridUpdates,
    ID = ThisItem.ID,
    {
        Titre: txtTitle.Value,
        Description: dpDescription.Value,
        'Due Date': dpDueDate.SelectedDate,
        Priority: {Value: dpPriority.Selected.Value},
        Auteur: combobox_usagers.Selected
    }
)
 
 
 
 
The "save" button OnSelect code :
 
Patch(
    Tasks,
    ShowColumns(
        colGridUpdates,
        "Title",
        "Description",
        "DyeDate",
        "ProjectLookup",
        "Priority",
        "Auteur",
        "ID"
    )
);

Select(btnLoadGrid);
Notify("Tâche sauvegardée", NotificationType.Success, 3000)
 
 
 
The btnLoadGrid OnSelect code :
 
ClearCollect(
    colGridData,
    Filter(
        Tasks,
        'Project Lookup'.Value = RecordsGallery1.Selected.Titre
    )
);

Clear(colGridUpdates);
Set(varReset, false); Set(varReset, true);
 

 

 

 

 

 

 

Categories:
  • trogne Profile Picture
    59 on at

    If I have 5 entries and add a person on an entry, I'll get an update collection of 5 items that does not get cleared.

     

    If remove the person and save : the update collection drops to 1 entry that does not get cleared.

     

    If I save again, it is finally cleared.

     

    So strange

  • james1994 Profile Picture
    231 Moderator on at

    Hey @trogne,

     

    I think the issue is because of your OnChange running and Collecting your gallery input. Your Save button sets a variable (varReset) which I assume is used to reset the combo box control in the gallery.

    Are you changing that combo box field to another person? If you are, I believe what is happening is the combo box resets back to default, which triggers the OnChange property resulting in the collection of the item.

     

    If you removed the Select(btnUpdate) on the OnChange property of the combo box, does the collection still not get cleared when you click the Save button?

  • trogne Profile Picture
    59 on at

    Everything works fine without the "OnChange" property on the combobox !   "update" collection is cleared, and all is saved well.

     

    What can I do instead of "Select(btnUpdate)" for that combobox ?

     

     

    The varReset is just used at the "TasksGallery" Items property :

    Sort(Filter(colGridData, varReset), ID, SortOrder.Descending)
     
    And at the end of "btnLoadGrid" OnSelect property :
    Set(varReset, false); Set(varReset, true);
  • james1994 Profile Picture
    231 Moderator on at

    I would remove the OnChange.

    Is colGridUpdates just the changes made to colGridData?

    If so, you could update that collection directly, then perform your patch to colGridData instead of colGridUpdates. That way you wouldn't need to bother with a second collection.

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 402 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 296 Most Valuable Professional

Last 30 days Overall leaderboard