cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted

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
Highlighted
Super User III
Super User III

@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?

 

 

 

Highlighted

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?

Highlighted

@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.

Highlighted

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.

Highlighted

@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."

 

Highlighted

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

Highlighted

@U_Idigoras 

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

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (10,058)