cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
U_Idigoras
Helper I
Helper I

Open form on View mode depending on field value

Hi, my school uses a PowerApps form to manage student data.

 

Each student has to submit a form with their personal data (name, age, country, etc), once submited a teacher checks that is all good and changes a Yes/No field value to True (this field is not visible for students).

 

What I want is, once that field has True value, the forms has to open in View mode.

I tried putting this on App.OnStart:

  • If(DataCardValue20.Value = false; FormMode.Edit; FormMode.View)
  • If(DataCardValue20.Value = false; DisplayMode.Edit; DisplayMode.View)
  • If(DataCardValue20.Value = false; Form1.DisplayMode = DisplayMode.Edit; Form1.DisplayMode =DisplayMode.View)

Nothing seems to work.

1 ACCEPTED SOLUTION

Accepted Solutions

Thank you, you reminded me of the SharePointIntegration!

Turns out I could just put the If in the OnEdit function of the SharePointIntegration.

 

If(DataCardValue20.Value = true; ViewForm(Form1); EditForm(Form1))

 

It works!

View solution in original post

7 REPLIES 7
mdevaney
Super User
Super User

@U_Idigoras 

App.OnStart runs before any controls in the PowerApp are loaded.  The problem is likely caused by the Form not yet existing.  You'll need to modify your code to look at the datasource instead of the form.

 

Change this code

If(DataCardValue20.Value = false; FormMode.Edit; FormMode.View)

 

Into this

If(
    LookUp(your_datasource_name,ID=your_id_number,your_column_name)=True;
    FormMode.View,
    FormMode.Edit
)

 

If you need more help please show me what your app looks like in a screenshot.  How does your app know what form to open?

 

 

 

I understand what you are saying...but how do I get the ID?

If the issue is the Form doesn't yet exists, then I can't get the ID?

@U_Idigoras 

If you show me some example screenshots of how a user would navigate to the form in your app it is likely I could show you how to obtain the ID.

Sorry, I didn't explain clearly. It's not an app, it's a custom SharePoint form.

 

I need users to be unable to edit elements.

@U_Idigoras 

The fact that you are using an SP Custom Form makes this much easier.  You can obtain the ID with this code.

SharePointIntegration.SelectedListItemID

 

Put this code in the OnEdit property of your SharePoint integration

If(   
    LookUp(
        your_datasource_name,
        ID=SharePointIntegration.SelectedListItemID,
        your_column_name
    )=True;
    FormMode.View,FormMode.Edit
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

Thank you, you reminded me of the SharePointIntegration!

Turns out I could just put the If in the OnEdit function of the SharePointIntegration.

 

If(DataCardValue20.Value = true; ViewForm(Form1); EditForm(Form1))

 

It works!

View solution in original post

@U_Idigoras 

Good stuff.  I am always glad to help get someone unstuck.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,941)