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 Platform Community / Forums / Power Apps / Show fields based on v...
Power Apps
Unanswered

Show fields based on value and then hide after button click

(0) ShareShare
ReportReport
Posted on by 11

Hi all, 

 

I am hoping someone can help me in creating a formula that shows and hides fields based on two unrelated conditions. The form I have built is for recording training sessions. Some training sessions have 1 trainer and 1 trainee, while others have multiple trainees. I have a text box that is the user is required it input the number of trainees. Based on the number inputted, it will display the correct amount of drop down menus with employees names and Pen Inputs for them to sign in. After they have signed, I have a save button which triggers my flow to save the signature as an image. I want the save button to also hide the drop down menu and signature pen input once it was been pressed. I have tried a number of formulas but it either doesn't show any fields when I put a value into the text box, or doesn't hide them once the save button is pressed. I have listed two different methods I've tried below. Any help would be greatly appreciated!  

 

First method: 

Set the Visible property of my data card to:

If(Value(Txt_Number_Trainee1.Text)>=2,true,Btn_Trainee1_Save.Pressed,false)

This works for the visibility based on the number of trainees, but doesn't hide the fields when I press the save button.

 

Second method tried: 

Set an UpdateContext on the OnVisible property of my form screen to:

UpdateContext({ShowT1: false})   (I don't want the fields to be visible by default when going into the form)

I sent the Visible property of the data card to:

If(Value(Txt_Number_Trainee1.Text)>=2,true,ShowT1,false)

and then the OnSelect property of my save button to:

UpdateContext({ShowT1:false});
OJT_TraineeSignature_1.Run(varReqID,Mid(JSON(PenTrainee1.Image,IncludeBinaryData),24,
Len(JSON(PenTrainee1.Image,IncludeBinaryData))-24));
Notify("Signature Saved",NotificationType.Success)

 

This still shows the fields based on the values, but wont hide the data cards after pressing the save button. 

 

HPax_0-1674144559887.png

HPax_1-1674144637215.png

 

 

 

Categories:
I have the same question (0)
  • bapala Profile Picture
    247 on at

    Try below and see if this works:


    OnVisible of the Screen: UpdateContext({ShowT1: false})
    Visible proprty of the Datacard: ShowT1
    OnSelect of the button: If(Value(Txt_Number_Trainee1.Text)>=2,UpdateContext({ShowT1: true}),false)

  • HPax Profile Picture
    11 on at

    I cant keep the Visible property of the Datacard: ShowT1 because I need the number of trainees to be the first condition its checking for on whether the Datacard containing the drop down menus and signatures remain hidden or become visible. I need the sequence to go: 

    1. Default mode when starting a new form: all DataCards visible, false 

    2. User enters number of trainees: appropriate number of DataCards visible, true  

    3. User signs PenInput and hits the save button: DataCards visible, false 

  • HPax Profile Picture
    11 on at

    I cant keep the Visible property of the DataCard: ShowT1 because I need the number of trainees to be the first condition its checking for on whether the DataCard containing the drop down menus and signatures remain hidden or become visible. I need the sequence to go: 

    1. Default mode when starting a new form: all DataCards visible, false 

    2. User enters number of trainees: appropriate number of DataCards visible, true  

    3. User signs PenInput and hits the save button: DataCards visible, false 

  • Verified answer
    bapala Profile Picture
    247 on at

    use 'onchange' proprty of the Txt_Number_Trainee1 with following formula:
    If(Value(Self.Text)>=2,UpdateContext({ShowT1: true}),false)

    In the OnSelct property of the button:
    UpdateContext({ShowT1: false})

    So finally your formula looks like below:

    OnVisible of the Screen: UpdateContext({ShowT1: false})
    OnChange of 'Txt_Number_Trainee1': If(Value(Self.Text)>=2,UpdateContext({ShowT1: true}),false)

    Visible Property of 'Names' and PenInput controls: ShowT1
    OnSelect of the button: UpdateContext({ShowT1: false})

  • HPax Profile Picture
    11 on at

    That worked! Only change I had to make was adding conditions for each number of trainees. 

     

    So my final formulas were: 

    OnVisible of the Screen: 

    UpdateContext({ShowT1: false});

    UpdateContext({ShowT2: false});

    UpdateContext({ShowT3: false});

    UpdateContext({ShowT4: false});

    UpdateContext({ShowT5: false});

    UpdateContext({ShowT6: false});

    UpdateContext({ShowT: false});


    OnChange of 'Txt_Number_Trainee1':

    If(Value(Self.Text)>=2,UpdateContext({ShowT1:true}),false);  If(Value(Self.Text)>=3,UpdateContext({ShowT2:true}),false);
    If(Value(Self.Text)>=4,UpdateContext({ShowT3:true}),false);
    If(Value(Self.Text)>=5,UpdateContext({ShowT4:true}),false);
    If(Value(Self.Text)>=6,UpdateContext({ShowT5:true}),false);
    If(Value(Self.Text)>=7,UpdateContext({ShowT6:true}),false);

    If(Value(Self.Text)>=2,UpdateContext({ShowT:true}),false);

    Visible Property of 'Names' and PenInput controls: ShowT1 (T2, T3,....) respectively 
    OnSelect of the button: UpdateContext({ShowT1: false}) - changed "ShowT#" respectively 

     

    Thanks so much!! 

  • bapala Profile Picture
    247 on at

    If I answer your Question? Please Click Accept as Solution

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 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard