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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Setting up a variable ...
Power Apps
Unanswered

Setting up a variable onVisible

(0) ShareShare
ReportReport
Posted on by 143

I have created a simple form from a SharePoint list which contains 4 text fields (Field 1,2,3 and Status) 

 

In the form I have 3 buttons outside the SharePoint Form, Employee, Line Manager and Escalation. When you press any of the button it will show the relevant field (Employee = Field 1, Line manager = Field 2 and so on) by setting a variable to the value of the button. The fields have the visible property set to the variable to show the right field. 

 

After each stage I am updating the Status to show its moved to the next stage. 

 

What I would like to do is when a user opens the form, depending on what stage (Status) its at, I would like to show the appropriate  field set but how do I access the Status value for the record with onVisible?

Categories:
I have the same question (0)
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Dhiran 

    You could try a Switch statement 

     

    OnVisible = Switch(Status.Value,

                       "Employee", Set(Field1_variable, true),

                       "Line Manager, Set(Field2_variable,true)

                      ... and so on

    )

     

    I need a little more detail to give an exact answer but this code gives you the basic structure.

  • Dhiran Profile Picture
    143 on at

    Hi @Anonymous 

    Thanks for the suggestion. I tried that on a very simple form and the screen does not even update when I click on a existing record. 

     

    Screenshot.png

    OnVisible.png

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Dhiran 

    Can you please share your code. How are you setting your show/hide variables? My suggest was very generic so you would need to adjust to suit your situation. Without any code reference I cannot support you further.

  • Dhiran Profile Picture
    143 on at

    Hi @Anonymous 

     

    I subsequently found that if I use SharePoint Integrated function, I can get the value of any column in the current record. 

     

    So my onVisible property is set to 

    If(IsMatch(SharePointIntegration.Selected.'Accident Report Status',"LineManager"),Set(varFormTab,"Line Manager"),If(IsMatch(SharePointIntegration.Selected.'Accident Report Status',"HSC"),Set(varFormTab,"HSC Evaluation"),Set(varFormTab,"Employee"))) 

     

    but it the next problem is that if evaluates the if statement before it loads the form and therefore every single time its set to "Employee"

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Dhiran 

    Try removing the second If() statement. In PowerApps, the If Statement looks like this

     

    If( Condition1, ThenResult1, [Condition2, ThenResult2] ... [, DefaultResult)

     

    So you chain conditions with the required result you want

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard