Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

ClearCollect / Patch / Collect - Dataverse Yes/No with modern checkbox

Posted on by 157
Hello, 
 
Simply put I cannot workout how to patch a modern control checkbox to a collection (patching to dataverse works fine). 
 
Some background:
 
I am creating a canvas app (in the Teams interface) built on Dataverse for Teams. I have a simple table (follow) with three columns:
kit (text type) | item (text type)| checked (Yes/No type)
 
In my app I collect the table in the onStart, ClearCollect(follow, localFollow) , the checked (Yes/No type column) is populated with a question mark, internally it has ID:true/false and Value:Yes/No
 
In a gallery each item has a modern control checkbox: 
Checked = LookUp(CheckboxStates, item = ThisItem.item && kit = drpKit.Selected.Value).checked
 
When a user checks an unchecked checkbox it patches to the follow table
 
Patch(
        follow,
        If(
            IsBlank(LookUp(follow, kit = drpKit.Selected.Value && coussin = ThisItem.item)),
            Defaults(follow),  
            LookUp(follow, kit = drpKit.Selected.Value && coussin = ThisItem.item) 
        ),
        {
            kit: drpKit.Selected.Value,
            coussin: ThisItem.item,
            checked: true
        }
    )
 
Everything works fine just to there but I am completely stuck on how to patch the collection: 
 
        {
          kit: drpKit.Selected.Value,
          item: ThisItem.item,
          checked:  true     <---------- THIS IS THE PROBLEM
        }
 
In place of checked: true I have tried: 
 
checked: {ID: true}
checked:  {Value: "Yes"}
checked: Checkbox.Checked
checked: If(Checkbox.checked = true, true, false)
I have tried using the display name of the field and the schema name - but nothing validates - copilot has me going in circles - can anyone help ? 

P.S
The only way I have got the patch to work is like this (looking up the checked status in the dataverse table after the table patch - which is not a good solution)
        {
          kit: drpKit.Selected.Value,
          item: ThisItem.item,
          checked: LookUp(follow, kit = drpKit.Selected.Value && item = ThisItem.item).checked
        }
 
  • Verified answer
    ronaldwalcott Profile Picture
    ronaldwalcott 1,167 on at
    ClearCollect / Patch / Collect - Dataverse Yes/No with modern checkbox
    Dropdowns appear to be the only control which interact in an acceptable manner with dataverse choice columns.

    A roundabout approach which may provide some insight is that you can use a dropdown for the update, make it invisible and use the checkbox to set the default item on the dropdown.

    e.g. I have a table called Usages and a choice called TestChecked.
    I can create the collection
    ClearCollect(testCollectionChecked, Usages);
    but I still need to get the option set from the dataverse table.
    So I can have a dropdown where the items are 
    Choices([@Usages].TestChecked)

    I can then use a checkbox and set the defaultselecteditems of the dropdown based on the checkbox
    If(CheckboxCanvas1.Checked,
    LookUp(Choices([@Usages].TestChecked),  'TestChecked (Usages)'.Yes),
    LookUp(Choices([@Usages].TestChecked),  'TestChecked (Usages)'.No))

    Not sure how the checked, unchecked are triggered so you may have to set to No for the unchecked.

    The Patch can then be based on the value in the dropdown. As a test just patching the first record.

    Patch(Usages, First(testCollectionChecked),{TestChecked: DropdownCanvas3.Selected.Value})

    Hopefully this can help in some way.




     

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,591

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,090

Leaderboard