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 / Change Edit Mode depen...
Power Apps
Answered

Change Edit Mode depending on data value

(0) ShareShare
ReportReport
Posted on by 23

I have created a custom Edit form for a List, which works fine.  If the Year, which is a choice field in the List, = 2021, I want to reset the FormDisplayMode to View.  Otherwise, use default Mode of Edit.  I am trying to figure out when/where to test the Year value to perform the reset.

Thanks, Eric

Categories:
I have the same question (0)
  • PowerRanger Profile Picture
    3,458 Super User 2024 Season 1 on at

    @ECBrinsfield So you have a customized Form, right?

     

    If yes, plese have a Look at the properties of the SharePointIntegration Object. 

    You will have OnEdit, OnNew and OnView

     

    So in OnEdit you will see something like EditForm(Form1)....This will tell the Form to show as Edit-Form. 

    So here you would need to place your formular which will look something similar like this:

     

    If(Year(SharePointIntegration.Selected.Created) <= 2021,ViewForm(SharePointForm1), EditForm(SharePointForm1)

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • ECBrinsfield Profile Picture
    23 on at

    Yes.  I have a custom view.  The Year column is defined as a Choice in the List.  I added the following code to OnEdit:

    Set(
    varYearSelected,
    Year(SharePointIntegration.Selected.Created)
    );
    If(
    Year(SharePointIntegration.Selected.Created) <= 2021,
    ViewForm(SponsorForm),
    EditForm(SponsorForm)
    );

     

    No errors, but the code does not work.  I added a label field to display the value of Selected.Created.  No matter how I enter or which year I open, the result is always 2022, which is the Default value for new.  So far, it does not work.  I think we are close.  

     

    I can't find the doc on Selected.Created.  Can you point me to that?

    Thanks, Eric

  • PowerRanger Profile Picture
    3,458 Super User 2024 Season 1 on at

    @ECBrinsfield Oh, I see. Whats the name of the Year column in your List?

  • ECBrinsfield Profile Picture
    23 on at

    Year

     

  • ECBrinsfield Profile Picture
    23 on at

    OH.  Duh.  I see.

     

  • PowerRanger Profile Picture
    3,458 Super User 2024 Season 1 on at

    @ECBrinsfield 🙂 Ok. And you said it is a choice field. Try this formular

     

    If(
    Value(SharePointIntegration.Selected.Year.Value) <= 2021,
    ViewForm(SponsorForm),
    EditForm(SponsorForm)
    );

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

     

     

  • ECBrinsfield Profile Picture
    23 on at

    OK.  Thanks.  I have had trouble with the Choice fields.  This helps a bunch.  

    The new code works better now, but there seems to be a lag.  If I select a record in the list and click on Edit at the top of the page, the new form opens with the Year from the last time I opened the form.  In other words, SharePointIntegration.Selected.Year.Value reflects the value of the lasts time I opened the Edit/View form.  

     

    So, this is a partial solution.  Any other suggestions?

  • ECBrinsfield Profile Picture
    23 on at

    Any more thoughts on this?  Still not working.  Thanks

  • ECBrinsfield Profile Picture
    23 on at

    Sorry, but this is not resolved.  

     

  • PowerRanger Profile Picture
    3,458 Super User 2024 Season 1 on at

    @ECBrinsfield please try this. Instead of directly using SharePointIntegration.Selected Property use this

     

    Set( selectedLookupItem,
     LookUp( YourSharepointIntegrationObject, 
     ID=SharePointIntegration.SelectedListItemID ) );

     

    So you would make a lookup to the SharePoint list (change Your Sharepoint Integration Object with your datasource Name) and then use the variable selectedLookupItem variable instead of SharePointIntegration.Selected

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

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

#2
11manish Profile Picture

11manish 207 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 177

Last 30 days Overall leaderboard