MscrmTools / PCF-Controls

Controls using PowerApps Components Framework
GNU General Public License v3.0
80 stars 42 forks source link

NN Checkboxes: All checkboxes are checked on load #111

Closed CasperJuulGregersen closed 1 year ago

CasperJuulGregersen commented 1 year ago

When loading the page, all checkboxes are checked.

I have a project table and a tag table. A N:N relation between these two table exists. The control works very well when I manually select or deselect a tag, but when the page is refreshed all tags are checked (however, the saved data are correct)

image image

MscrmTools commented 1 year ago

I tried to reproduce but w&s not able to... Can you share the way you configured the control?

CasperJuulGregersen commented 1 year ago

Hi MscrmTools,

Thanks for getting back to me regarding this issue.

I’ve added some screenshots from the configuration, my Tag table and the relationship between this and my Initiative table. The NN-control is inserted on a form in the Initiative table, and I have two records in the Tag table. Please let me know if you have any questions.

@.***

@.***

@.***

@.***

Kind Regards / Venlig hilsen,

Casper Lindy Gregersen | Senior Consultant @.*** | +45 2630 8988

www.projectum.comhttps://t-eu.xink.io/Tracking/Index/TSoAAFSrAAAV72MA0 | Follow us on LinkedInhttps://t-eu.xink.io/Tracking/Index/TioAAFSrAAAV72MA0 | Follow us on YouTubehttps://t-eu.xink.io/Tracking/Index/TyoAAFSrAAAV72MA0

From: MscrmTools @.> Sent: Monday, 5 December 2022 15.18 To: MscrmTools/PCF-Controls @.> Cc: Casper Lindy Gregersen @.>; Author @.> Subject: Re: [MscrmTools/PCF-Controls] NN Checkboxes: All checkboxes are checked on load (Issue #111)

Du får ikke ofte mails fra @.**@.>. Få mere at vide om, hvorfor dette er vigtigthttps://aka.ms/LearnAboutSenderIdentification

I tried to reproduce but w&s not able to... Can you share the way you configured the control?

— Reply to this email directly, view it on GitHubhttps://github.com/MscrmTools/PCF-Controls/issues/111#issuecomment-1337447942, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOB7ZIWLBUZECTXIRJJOP6TWLX2R5ANCNFSM6AAAAAASHVZF3Y. You are receiving this because you authored the thread.Message ID: @.**@.>>

alanrroberts commented 1 year ago

I am seeing a similar issue. By default all of the checkboxes are checked. If I add a subgrid so I can see any related records I have noticed the following...

1) Even though the checkboxes default to selected, there are no records in the associated subgrid. 2) Unticking and ticking checkboxes doesn't add records to the related subgrid 3) Manually adding records to the subgrid and then unticking the checkboxes does cause them to be removed.

So Unticking is removing records but ticking isn't adding them and all checkboxes default to ticked regardless of whether there are related records or not.

All I have configured in the control is the name of the related table, the view and the label column. I have also tried manually specifying the relationship but this didn't make a difference.

Cheers

Alan

MscrmTools commented 1 year ago

Would it be possible to get the configuration for the PCF? Also, are you using latest version?

alanrroberts commented 1 year ago

Hi, yes it is the latest version. Can you be more specific about what configuration you want? As mentioned above, I have only configured the name of the related table, the view to use and the column to use for the label. Everything else is left blank. The control does correctly show the labels for the records in the related table. Happy to provide any additional info or set up a screen share if that would help.

MscrmTools commented 1 year ago

A screenshot of the configuration just to be sure I see the whole picture.

CasperJuulGregersen commented 1 year ago

It’s not a specific configuration, I want – not yet at least, I’m just investigating the PFC control, which looks really nice (besides this issue).

I just noticed that when the form loads, all options are always checked by default. In my test/example above, I have two records (Business and Family) in my list of tags, and only Business is related to the record in the project table, but both Business and Family are checked on form load.

Kind Regards / Venlig hilsen,

Casper Lindy Gregersen | Senior Consultant @.*** | +45 2630 8988

www.projectum.comhttps://t-eu.xink.io/Tracking/Index/TSoAAFSrAAAV72MA0 | Follow us on LinkedInhttps://t-eu.xink.io/Tracking/Index/TioAAFSrAAAV72MA0 | Follow us on YouTubehttps://t-eu.xink.io/Tracking/Index/TyoAAFSrAAAV72MA0

From: MscrmTools @.> Sent: Saturday, 17 December 2022 20.44 To: MscrmTools/PCF-Controls @.> Cc: Casper Lindy Gregersen @.>; Author @.> Subject: Re: [MscrmTools/PCF-Controls] NN Checkboxes: All checkboxes are checked on load (Issue #111)

Du får ikke ofte mails fra @.**@.>. Få mere at vide om, hvorfor dette er vigtigthttps://aka.ms/LearnAboutSenderIdentification

A screenshot of the configuration just to be sure I see the whole picture.

— Reply to this email directly, view it on GitHubhttps://github.com/MscrmTools/PCF-Controls/issues/111#issuecomment-1356422143, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOB7ZIVJCPPFQDDJKNRN3MDWNYJXFANCNFSM6AAAAAASHVZF3Y. You are receiving this because you authored the thread.Message ID: @.**@.>>

alanrroberts commented 1 year ago

image image image

I've tried with an without specifying the relationship manually.

Thanks

Alan

CasperJuulGregersen commented 1 year ago

Hi Alan,

“The control does correctly show the labels for the records in the related table.” Just to be clear, it’s not about the control not showing the labels correctly, it’s about all labels being checked when the form loads.

Kind Regards / Venlig hilsen,

Casper Lindy Gregersen

alanrroberts commented 1 year ago

Yep that is correct. All labels show correctly but are checked.

image

Even though they show checked, they are not marked as related records though. Unchecking and checking them also doesn't add them as related records.

MscrmTools commented 1 year ago

When you only have one relationship between both tables, there is no need to specify the relationship. I Don't know if this is the case for your implementation. But can you try not to specify anything in this parameter?

alanrroberts commented 1 year ago

Yep saw this in the documentation and tried it with and without a relationship specified and the result is the same.

MscrmTools commented 1 year ago

This is so weird because I really do not reproduce it... :(

In the code, the only location where it is ticking checkboxes is after having read the information sent by the platform about related records. I don't see at all how it could check all records...

alanrroberts commented 1 year ago

Do I need to have any specific settings on the underlying subgrid? At the moment it looks like this...

image

MscrmTools commented 1 year ago

I don't think so... Do you have any dev skills so that I can ask you to peform some debug in browser console?

MscrmTools commented 1 year ago

Found it! Maybe... You did not tick "Show related records", so that it sends all records

alanrroberts commented 1 year ago

I haven't played with PCF controls but have basic js skills if that helps. Happy to open up the console and check things for you.

MscrmTools commented 1 year ago

Did you see my latest comment : Found it! Maybe... You did not tick "Show related records", so that it sends all records

alanrroberts commented 1 year ago

I wondered about that but thought it was suppose to show all records (in order to show the ones not selected as well as the selected ones)? If I try and tick the "show selected records" option in the designer I get an error.

image

alanrroberts commented 1 year ago

OK, removed/deleted the checkbox list control and checked the "show related records" field with just the standard subgrid showing. That allowed me to save the form. Then added the checkbox list control back and saved again. Now it is behaving a little differently.

When I open a form the records are no longer all selected :) Only the correct records are selected :) If I unselect a record, the record is correctly removed from a subgrid I have showing on the page :)

The only problem I have is that if I deselect a record and click save, the record is correctly removed from the additional standard subgrid I have showing, but on saving, the deselected record in the checkbox list get selected again.

Starting with 2 records selected (checkbox list view at the top, standard subgrid underneath) image

Deselect the "Has the order..." option image

Refresh the subgrid image

So the subgrid is showing the correct data but the checkbox control has reselected the record.

alanrroberts commented 1 year ago

p.s. hitting refresh updates the checkbox control so everything matches image

MscrmTools commented 1 year ago

This might be a caching issue... I will try to reproduce this one but I guess we can finally close this issue

alanrroberts commented 1 year ago

Thanks for your help!

CasperJuulGregersen commented 1 year ago

That approach do also work for me: Add the default subgrid with Show related records selected. Save the form and then change the control to the Checkbox List.

Thanks for looking into this - really helpful!