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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Apps
Answered

Checkbox issue

(0) ShareShare
ReportReport
Posted on by

m facing an issue with two checkboxes in my Power Apps form. One checkbox is for "Active Contract" and the other is for "Non Active Contract." The default values of these checkboxes are linked to a SharePoint column, where the "Active Contract" checkbox is set to ThisItem.ActiveContract and the "Non Active Contract" checkbox is set to !ThisItem.ActiveContract.

Problem:

The problem is that when the form loads, the "Non Active Contract" checkbox is automatically checked because its default value is !ThisItem.ActiveContract

Categories:
I have the same question (0)
  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @Anonymous,

     

    Is the issue that this non active contract is automatically selected when creating a new record? In this case you could give the following a try:

     

    //Default value (change Form1 to the correct name)
    !ThisItem.ActiveContract && Form1.Mode <> FormMode.New

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

  • Community Power Platform Member Profile Picture
    on at

    Thanks for your response, the issue is both the fact that when the user goes to create a new item so in the empty form, the Not Active contract checkbox is being checked automatically due to the fact that its default value is !Thisitem.Activecontract which is a Yes/No column with  adefault value of No. Secondly is the fact that both checkboxes can be checked. I want to make it so that it is either one or the other, checking one would uncheck the other.
    Screenshot of what the user sees when presses on new item: 

    PaulHajjar_0-1692019052524.png

    As you can see the box is checked, here is another screenshot to show you that both can be selected simultaneously.
    I also have an issue with as you can see above, I have a checkbox called Requesting for someone else, I have set its default value to Thisitem.Requesting for someone Else . When the box is checked, a field campaign owner appears. I have a problem where when I open a new form, even though the box is unchecked and the default value of the yes/no column in sharepoint is No, the field campaign owner appears, I have to check it then uncheck it for it to dissapear.

  • Community Power Platform Member Profile Picture
    on at

    PaulHajjar_1-1692019190073.png

     Here is the screenshot I forgot to upload about the two checkboxes being checked simultaneously

  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @Anonymous,

     

    Using a variable to keep track of the true/false value and force a single selection, could do the trick. With this set-up I expect that this screen is only used to create new items.

     

    (1) In the OnVisible of the New Form screen write:

    UpdateContext({varActive: Blank()});

     

    (2) Properties of the Active Contract checkbox:

    //OnCheck
    UpdateContext({varActive: true}); 
    Reset(CheckboxNameNonActive)
    
    //Default
    varActive

     

    (3) Properties of the Not Active Contract checkbox

    //OnCheck
    UpdateContext({varActive: false}); 
    Reset(CheckboxNameActiveContract)
    
    //Default
    !varActive && !IsBlank(varActive)

     

    In regards to the field campaign owner: do you want to hide the 'Campaign Owner' DataCard when the checkbox is not checked? If so, set the Visible property of the Campaign Owner Datacard to:

    //Change to the correct checkbox name
    CheckboxNameRequest.Value

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

  • Community Power Platform Member Profile Picture
    on at

    So for the issue of the active contract checkbox, the issue is half resolved because yes it did do  what I wanted to but now when a form is submitted and a user wants to see it, the value of the checkbox is not saved and the information is lost. This is why I had originally put the default value as Thisitem.Activecontract and !Thistem.Activecontract 

    Also for the second issue, the visibility property is already that, my problem is that when a new item is pressed and the user has to fill the new form, the campain owner field appears as if the checkbox was checked but the default value of the check is Thistem.Sharepointcolumnname and the default value of that column is a yes/no and is set to no so it is weird that it is acting as if it was checked and therefore to make the field disappear I have to check it and uncheck it I will post a screenshot below showing what happens when a new form is opened and you will see how the check is not ticked but the field is there

    PaulHajjar_0-1692025965814.png

     

  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @Anonymous,

     

    Regarding the first issue: Normally patching the data should remain the same, since this was unchanged. Visualizing the patched data could indeed be affected by the code, because we no longer refer to the column value.

     

    If you are using the same screen & form to edit data and create new records, a small adjustment will have to be made.

     

    OnVisible of the screen:

    If(
     FormName.Mode = FormMode.New,
     //Set blank when creating a new record
     UpdateContext({varActive: Blank()}),
     //Else set to the saved value
     UpdateContext({varActive: RecordReference.ActiveContract});
    )

    In the code above change RecordReference to the code in the Item property of that Form. (e.g. Gallery.Selected or a variable in which the record is stored)

     

    In regards to the second issue, I was able to recreate that strange behaviour. Changing the Visible property to the code below fixed the issue:

    CheckboxNameRequest.Value = true

     

    I hope this helps!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard