cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Cooper
New Member

Make datacards required once visible in form / Make datacards required if different datacard has a value entered in it

Hello,

 

I have a NewForm connected to an excel file. There are checkboxes on the page which make certain datacards visible. When these datacards become visible upon selection of the checkbox I'd like them to be required fields. When they are hidden I would like them to be unrequired.

 

Alternatively, I'd like to make datacards required if a different data card has a value entered in it. for example, if there is a data card for Product Description and Product Code, I'd like to make the product code datacard required when there is a value entered in the product description datacard.

 

Both of these solutions are equally valid and any help is much appreciated!

 

Thanks!

Cooper

2 ACCEPTED SOLUTIONS

Accepted Solutions
Dual Super User
Dual Super User

Re: Make datacards required once visible in form / Make datacards required if different datacard has a value entered in it

Hi @Cooper 

 

For making certain data cards visible only when the checkbox is checked, you can set a global variable when the checkbox is checked, this can be done by updating the "OnCheck" property as:
Set(CheckboxChecked, true)
 
"OnUncheck" -> Set(CheckboxChecked, true)
 
Also, set the visible property of your datacards as: CheckboxChecked
 
Regarding the second use case, you can modify your datacard's required property based on the same variable created as part of first item:
 
DataCard -> Required -> If(CheckboxChecked,true,false)
 
You can use this expression on all the datacards wherever required.

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

Cooper
New Member

Re: Make datacards required once visible in form / Make datacards required if different datacard has a value entered in it

Hi @yashag2255 

 

This was a great solution but I have two edits to make it more clear for future people who come across this post.

 

1. Set the "OnUncheck" property to Set(CheckboxChecked, false) .... previously you had the Oncheck and OnUncheck properties both set to "true" and this kept powerapps from understanding the boolean nature of this function.

 

2. set the visible property of the datacards to If(CheckboxChecked,true,false). Yes, this is the same formula that you will put in the required property for the datacards. By doing this instead of setting the visible property to "CheckboxChecked," by default the datacards will not appear until the checkbox is checked and when you check the box it will make the fields required. both the visibility and requirement of these datacards will toggle with the checkbox. When you set the visible property to just "CheckboxChecked," by default the datacards are visible when you first enter the page even though the checkbox is unchecked by default (you should not be able to see the cards until the box is checked). Then, upon the first check of the box they become required (you see a star appear next to the title) and upon first uncheck they disapear. After that, the functionality works fine. Using the If statement just makes it so that when you first enter the page with the datacards and checkboxes that the datacards are not visible until you check that box.

 

everything else in your response worked great. Thanks so much!!

View solution in original post

3 REPLIES 3
Akatamaoka Advocate II
Advocate II

Re: Make datacards required once visible in form / Make datacards required if different datacard has a value entered in it

For your first scenario, it sounds like you can set the "Visible" and "Required" properties of the datacard to the Value of the Checkbox.

 

To test this, I tried to recreate the issue with input box fields instead of connecting to an Excel spreadsheet, but it should work the same way.

 

For my test:

  1. Add 2 checkboxes, Checkbox1 and Checkbox2
  2. Add 2 text input boxes, TextInput1 and TextInput2
  3. Set the "Visible" properties of the two input boxes to their corresponding checkboxes (here is where you would also change the "Required" properties
    TextInput1 Visible property: 
    Checkbox1.Value
    TextInput2 Visible property:
    Checkbox2.Value
  4. Checkboxes work as "true" or "false", so if a checkbox is checked, it's true, and if the Visible/Required properties are set to the value of the checkbox, they will also be true.

checkboxes.png

Dual Super User
Dual Super User

Re: Make datacards required once visible in form / Make datacards required if different datacard has a value entered in it

Hi @Cooper 

 

For making certain data cards visible only when the checkbox is checked, you can set a global variable when the checkbox is checked, this can be done by updating the "OnCheck" property as:
Set(CheckboxChecked, true)
 
"OnUncheck" -> Set(CheckboxChecked, true)
 
Also, set the visible property of your datacards as: CheckboxChecked
 
Regarding the second use case, you can modify your datacard's required property based on the same variable created as part of first item:
 
DataCard -> Required -> If(CheckboxChecked,true,false)
 
You can use this expression on all the datacards wherever required.

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

Cooper
New Member

Re: Make datacards required once visible in form / Make datacards required if different datacard has a value entered in it

Hi @yashag2255 

 

This was a great solution but I have two edits to make it more clear for future people who come across this post.

 

1. Set the "OnUncheck" property to Set(CheckboxChecked, false) .... previously you had the Oncheck and OnUncheck properties both set to "true" and this kept powerapps from understanding the boolean nature of this function.

 

2. set the visible property of the datacards to If(CheckboxChecked,true,false). Yes, this is the same formula that you will put in the required property for the datacards. By doing this instead of setting the visible property to "CheckboxChecked," by default the datacards will not appear until the checkbox is checked and when you check the box it will make the fields required. both the visibility and requirement of these datacards will toggle with the checkbox. When you set the visible property to just "CheckboxChecked," by default the datacards are visible when you first enter the page even though the checkbox is unchecked by default (you should not be able to see the cards until the box is checked). Then, upon the first check of the box they become required (you see a star appear next to the title) and upon first uncheck they disapear. After that, the functionality works fine. Using the If statement just makes it so that when you first enter the page with the datacards and checkboxes that the datacards are not visible until you check that box.

 

everything else in your response worked great. Thanks so much!!

View solution in original post

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

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