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

 

 

 

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (74,796)