cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate I
Advocate I

Only additional checked checkobxes are saved (not previously selected ones)

Hi,

 

When opening an existing record and checking some additional checkboxes then only the last checked items are saved. The previous items that were alread checked are not saved.

 

Some background information. I have 3 tables (in bold)

  • BigItems:
    • BigItems_ID
    • BigItems_Name
  • Checkout
    • Ch_ID
    • Ch_Employee
    • Ch_BigItems_Date
  • CheckoutBigItems:
    • ChBI_Ch_ID
    • ChBI_BigItems_ID

Maybe this image will give you a better idea.

Schermafbeelding 2017-10-17 om 17.59.56.png

There are no problems when creating new records by entering an ID, Name, Date and checking some checkboxes.

 

When I try to update an existing record, only the newly selected checkboxes are saved.

See the following example. There is an existing record with ID equal to 1 and employee is DAVID and the FIRST ITEM was saved in CheckoutBigItems table together with the checkout ID.

 

1stScreenA.jpg(see printscreen below) Now I check only the second item so that there are two items in total (but I didn't touch the previously selected checkbox). I click SAVE and for a second the screens changes to the screen in the middle of the printscreen and you see that only the second checkbox is selected and then it fades to the Browse screen (screen on the right) where you can see that only the second item was saved.

 

2ndScreen.jpg

 

 

So I think there is a problem with how the previously saved items are shown with DEFAULT from the Checbox (cbBigItems).

Or there is a problem with the ONSUCCES of  EditForm1.

 

Here are the codes I used:

 

In EDITSCREEN1 there is Gallery1 and  EditForm1. In Gallery1 there is only chBigItems and the DEFAULT is

 

If(!IsBlank(LookUp(CheckoutBigItems, ChBI_Ch_ID=BrowseGallery1.Selected.Ch_ID && 
ChBI_BigItems_ID=ThisItem.BigItems_ID)),true,false)

 

The OnSucces of the EditForm1 has the following code:

 

RemoveIf(CheckoutBigItems, ChBI_Ch_ID=EditForm1.LastSubmit.Ch_ID);

ForAll(Filter(Gallery1.AllItems,cbBigItems.Value=true), Patch(CheckoutBigItems,
Defaults(CheckoutBigItems), {ChBI_Ch_ID:EditForm1.LastSubmit.Ch_ID,
ChBI_BigItems_ID:BigItems_ID}));

Navigate(BrowseScreen1,Fade)

 

I followed the tutorial: UX Patterns: Multi-select

But I used Excel on OneDrive instead of SharePoint but I don't think that matters.

 

 

Any help is highly appreciated!

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Community Support
Community Support

Hi @Gosa,

 

Thanks for the feedback.

 

Please take a try with the steps below to fix it:

1. Under the OnSelect property of the Submit Button, modify the formula as below:

SubmitForm(EditForm1);ClearCollect(UpdatedData,Filter(Gallery1.AllItems,Checkbox4.Value))

2. Under the EditFrom1 OnSuccess property, edit the formula as below:

RemoveIf(CheckoutBigItems, ChBI_Ch_ID=EditForm1.LastSubmit.Ch_ID);
ForAll(UpdatedData, 
Patch(CheckoutBigItems, Defaults(CheckoutBigItems),
{ChBI_Ch_ID:EditForm1.LastSubmit.Ch_ID, ChBI_BigItems_ID:BigItems_ID})
); Navigate(BrowseScreen1,Fade)

 Doing it in this way should make it work as expected.

 

Regards,

Michael

Community Support Team _ Michael Shao
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

Highlighted
Community Support
Community Support

The reason that the original selected checkbox won't be kept should be caused by the Remove () function.

As its value is bound with the actual data, not the user selection.

Thus we create a collection to keep all the selected CheckBoxes, then patch the value.

 

Regards,

Michael

Community Support Team _ Michael Shao
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

7 REPLIES 7
Highlighted
Community Support
Community Support

Hi @Gosa,

 

Thanks for the feedback.

 

Please take a try with the steps below to fix it:

1. Under the OnSelect property of the Submit Button, modify the formula as below:

SubmitForm(EditForm1);ClearCollect(UpdatedData,Filter(Gallery1.AllItems,Checkbox4.Value))

2. Under the EditFrom1 OnSuccess property, edit the formula as below:

RemoveIf(CheckoutBigItems, ChBI_Ch_ID=EditForm1.LastSubmit.Ch_ID);
ForAll(UpdatedData, 
Patch(CheckoutBigItems, Defaults(CheckoutBigItems),
{ChBI_Ch_ID:EditForm1.LastSubmit.Ch_ID, ChBI_BigItems_ID:BigItems_ID})
); Navigate(BrowseScreen1,Fade)

 Doing it in this way should make it work as expected.

 

Regards,

Michael

Community Support Team _ Michael Shao
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

Highlighted
Community Support
Community Support

The reason that the original selected checkbox won't be kept should be caused by the Remove () function.

As its value is bound with the actual data, not the user selection.

Thus we create a collection to keep all the selected CheckBoxes, then patch the value.

 

Regards,

Michael

Community Support Team _ Michael Shao
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

Highlighted

Hi,

 

Thank you! That worked

 

1) SLOW: hide the galley somehow or show message?

Is it because of OneDrive (excel) that saving is slow? (see animated gif below)

Is there a way to hide what is happening after you pressed SAVE (just before you navigate to the first screen?)

After saving you see the chekcboxes being checked one by one (probably because of the FORALL-function).

I rather show a white box on top of the fields with a text: Data being processed or hide the gallery (with the checkboxes) somehow when it's being saved.

 

checked.gif

 

 

2) resetting DEFAULT values of checkboxes after previously submitted a form.

Also one small thing. When I edited the example above. I ended up having 4 checkboxes checked.

When I click on the PLUS-sign to make a new form. The checkboxes are still selected.

 

Schermafbeelding 2017-10-18 om 13.17.20.png

 

The default of the checkbox cbItems has the folowing:

If(!IsBlank(LookUp(CheckoutBigItems,
ChBI_Ch_ID=BrowseGallery1.Selected.Ch_ID &&
ChBI_BigItems_ID=ThisItem.BigItems_ID)),true,false)

In this is printscreen you see the Gallery on the left with the checkbox called cbBigItems

 

Schermafbeelding 2017-10-18 om 13.21.59.png

 

 

Thanks!

Highlighted

Hi @Gosa,

 

Please take a try to put the navigate () function before the clearcollect() function.

For your second question, take a try to modify the Default property of the CheckBox as below:

If(EditForm1.Mode=0,
If(!IsBlank(LookUp(CheckOutBigItem,
ChBI_Ch_ID=BrowseGallery1.Selected.Ch_ID && ChBI_BigItems_ID=ThisItem.BigItems_ID)
),
true,
false),
false)

Regards,

Michael

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

Hi Michael,

 

I appreciate it your help!

 

The second question worked with the code you provided! Thank you!

 

For the first question. You propably mean to put the navigate before the ForAll & UpdateDate in the EditFrom1 OnSuccess (since there is no clearcollect here)?

I tried it this way and indeed go to the first screen while it's still being saved so the problem of seing things happen while saving is gone.

The only thing I'm affaid of is that users might start clicking to start editing or adding new records while the saving process has not terminated. So the waiting time has shifted from the EditForm1 screen to the FirstScreen.

Is it best to draw a box and insert a label and use a variable to show hide a message.

 

Set(ShowMsg,true);
Navigate(BrowseScreen1,Fade);

RemoveIf(CheckoutBigItems, ChBI_Ch_ID=EditForm1.LastSubmit.Ch_ID);

ForAll(UpdatedData, Patch(CheckoutBigItems,
          Defaults(CheckoutBigItems), { ChBI_Ch_ID:EditForm1.LastSubmit.Ch_ID, 
ChBI_BigItems_ID:BigItems_ID}));
Set(ShowMsg,false)

And on the first screen I set the Visible of the Group(of the box & text) to ShowMsg?

Or is there a better way to do it.

 

Here you can see it in action: (you can see the small dots moving during the save)

saving.gif

 

Thanks for any advice!

 

ps: I'm still curious why the saving-process takes so long for such a small App with a not a lot of data in the excel-files on OneDrive. Any ideas if it's due to OneDrive?

Highlighted

Hi @Gosa,

 

Your solution is better.

Well, for the why part, that is out of my knowledge.

Based on what I experienced, that should be caused by Service request. Submitting new data would require PowerApps to start a new query to the data source, which should be the same as refresh the Gallery.

There are performance related ideas submitted under the Idea forum, you may create your own as a new user voice.

https://powerusers.microsoft.com/t5/PowerApps-Ideas/Storing-SQL-table-data-in-cache-memory-to-improv...

Regards,

Michael

 

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

Thank you Michael for all the answers and help!!!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (9,965)