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 DisplayMode of...
Power Apps
Answered

Setting DisplayMode of a Form based on a data range.

(0) ShareShare
ReportReport
Posted on by 99

I am building a job application submission app for an organization.  I have a gallery where currently posted jobs are viewable according to the open and close dates of each job.  The employee clicks on an "Apply" button found on the job announcement, which takes them to the application form  (EditForm_Application) .  They fill out the form and submit.  Then, they have an option to review their application and make changes as long as the job posting is still open.  I want to set the DisplayMode of the submitted application to DisplayMode.View ONLY during the time the job is posted.  

 

The logic, in my mind, should be as simple as something like this:

//CloseDate = Date Field (SharePoint Column)

If(DateDiff(CloseDate,Now(),Days) < 0,Edit,View)

 

However, that doesn't work.  I've tried to convert the DateDiff value to a number, then assign to a variable, then run an IF statement comparing the variable to zero, but that doesn't work either.  Lil' help!

Categories:
  • KRider Profile Picture
    577 Super User 2024 Season 1 on at

    Good afternoon!

    Why not try an UpdateContext right before the If?

    //CloseDate = Date Field (SharePoint Column)
    UpdateContext({dateCheck: DateDiff(CloseDate,Now(),Days)});
    If( dateCheck < 0,Edit,View)

    Hope this helps! 😄 

  • ShadyCheech Profile Picture
    99 on at

    Thanks for your response.  I tried the solution, but unfortunately, I am getting an error in the IF statement.  Do you have any other suggestions?  Thanks again.

  • KRider Profile Picture
    577 Super User 2024 Season 1 on at

    What is the error? I re-read the code did you want it to be? View when it's passed and edit when it isn't?

     

    //CloseDate = Date Field (SharePoint Column)
    UpdateContext({dateCheck: DateDiff(CloseDate,Now(),Days)});
    If(
    dateCheck < 0,
    View,
    Edit
    )

     

    How about this?

    If(
     ThisItem.CloseDate < Today(),
     DisplayMode.Disabled,
     DisplayMode.Edit
    )

     

  • ShadyCheech Profile Picture
    99 on at

    I received a red underline error under the "ThisItem" in your formula.  It would not recognize it.

     

    I tried this:

     

    OnVisible (property of the screen which holds the form):

     

    ShadyCheech_0-1689343266396.png

     

    DefaultMode (on the form serving as the application):

     

    ShadyCheech_1-1689343340589.png

    I am receiving an "Expected Enum value" error for the DefaultMode formula (the second formula above).  I'm not understanding why this isn't working.  I've tried to convert it by using "Value()", but it does not resolve the issue. 

     

    ShadyCheech_2-1689343915440.png

     

    I appreciate your effort in helping me with this.

  • Verified answer
    KRider Profile Picture
    577 Super User 2024 Season 1 on at

    I did this in a textbox/DisplayMode property in my environment and it worked:

    If(
     DateDiff(dteNAME_2.SelectedDate,Today(),TimeUnit.Days)<0,
     DisplayMode.Edit,
     DisplayMode.Disabled
    )

     it worked with Now() as well?

     

  • Verified answer
    Talha_Dar Profile Picture
    870 Super User 2024 Season 1 on at

    Hi @ShadyCheech,

     

    Please try using the provided code below as it has worked for me:

     

    If(
     condition,
     FormMode.Edit,
     FormMode.View
    )

     

    Give it a try and see if it resolves the issue for you as well.

     

    If you found my answer helpful, please consider giving it a thumbs-up or a like. Your feedback is greatly appreciated!

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • ShadyCheech Profile Picture
    99 on at

    Thanks.  Yeah, this may work for a text box but the 'DefaultMode' of the form will not accept it.  I am needing the entire form to be view only within the time frame the job announcement is active.  I did try your formula for some individual fields and it worked, so I'll just apply this to all the fields individually to achieve what I need.

     

    Thanks again for your help and quick responses.

  • ShadyCheech Profile Picture
    99 on at

    Thanks @Talha_Dar.  The above solution by @KRider worked for what I was needing.  

  • KRider Profile Picture
    577 Super User 2024 Season 1 on at

    No problem! Glad to help

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 354 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 330

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard