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 / Locking down a form ba...
Power Apps
Answered

Locking down a form based on a date field

(0) ShareShare
ReportReport
Posted on by 1,625

I have a canvas app which is liked to SP Online list.

 

I have a date field, I'd like to set the form to be read only if this date field has a date entered and the form is submitted using a save button, just to avoid any possibility of the form being changed.

Is this possible, anyone advise how I can set this up?

 

Thank You

 

Categories:
  • mdevaney Profile Picture
    29,993 Moderator on at

    @Lefty 

    You can accomplish by putting the DisplayMode property of each Card into disabled mode.

     

    If(
     !IsBlank(DataCardValue_DateField.SelectedDate)
     And DataCardValue_SavedForm.Value = true,
     DisplayMode.Edit,
     DisplayMode.Disabled
    )

     

    Note: in my solution I assumed there is a Yes/No column in SharePoint called SavedForm.  The toggle must be included in your form somewhere but you can set the Card's Visible property to false if you don't want it to appear.

     

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

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @Lefty ,

     

    Since Form turns to EditMode after submitted, based on your requirements, I think you just need to add ViewForm() function after SubmitForm function in SAVE button with some date field condition, please try this:

    1. Modify the Save button OnSelect property:

     

    If(IsBlank(DataCardValue1.SelectedDate),SubmitForm(FormName),SubmitForm(FormName);ViewForm(FormName)) //replace DataCardValue1 to the real control name of data field

     

    Test Result:

    GIF_50.gif

    Hope this helps.

    Sik

     

  • Lefty Profile Picture
    1,625 on at

    Hi @v-siky-msft 

    I cannot get this to work, I've set Save button on 1 screen to:

     

    If(IsBlank(DataCardValue31_1.SelectedDate), SubmitForm(Form3); ViewForm(Form3), SubmitForm(Form3));

    But after I put in a date and go back to this screen, the form is still editable.

     

    I will try @mdevaney which I can see will work, issue is it's a lot of fields to copy and paste the code into and I guess i was hoping there was a simpler way.

     

    Will report back shortly, unless i'm doing something wrong with @v-siky-msft suggestion?

  • mdevaney Profile Picture
    29,993 Moderator on at

    @Lefty 

    I can't comment on the solution of @v-siky-msft.  They will have to do that.

     

    From what I have observed most of the Microsoft folks post once per day in the evenings (North America) Sunday-to-Thursday.

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @Lefty ,

     

    Oh, You just reversed the logic order, if the date picker is not blank, set Form to View mode after submit

    please check this:

    If(!IsBlank(DataCardValue31_1.SelectedDate), SubmitForm(Form3);ViewForm(Form3), SubmitForm(Form3))

    or 

    If(IsBlank(DataCardValue31_1.SelectedDate), SubmitForm(Form3), SubmitForm(Form3);ViewForm(Form3)) 

     

    Sik

     

  • Lefty Profile Picture
    1,625 on at

    @v-siky-msft 

     

    Afraid I had tried both those statements prior to messaging back.

    I think I may not have been clear on what I want to achieve.

    I have a form which is first completed by any user, so User1, then User1 will insert any username for User2 to complete Part B.

    When User2 completed Part B and inserts a date in the date field, I want the form to never be editable by User1 or User2 or another user.

    It appears using either of the Fx does not achieve my requirement and i presume many people would like to lock down forms when they are complete?

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @Lefty 

     

    Got it.

     

    I have parsed your requirement to understand that if the date field in the current Form item of SP list is empty, the form can continue to edit, but if the date field is not empty, the form will be locked. So there is no need to check the date picker control, we need to check the date field in the current item of SP list.

    Please modify the DefaultMode property of Form as below:

     

    If(IsBlank(<Items property of Form>.DateFieldName),FormMode.Edit,FormMode.View) // put Items code into <Items property of Form>

     

    Test Result:

    Snipaste_2020-03-16_17-51-24.png

    Hope this helps.

    Sik

     

     

  • Lefty Profile Picture
    1,625 on at

    @v-siky-msft 

    Thanks

     

    If(IsBlank('List Name'.ColumnName), FormMode.Edit, FormMode.View)

    I've done the above, but now the items which do not have a date in the date field are also view only?

     

    Also this has now created a new request, is there a way to now make the save button greyed out if the form is in View mode?

     

     

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @Lefty ,

     

    Please show me the Items property of EditForm, it should be a record from SP list instead of the SP list itself.

    so the code:

    If(IsBlank(<put Items property here>.ColumnName), FormMode.Edit, FormMode.View)

     

    To make the save button greyed out if the form is in View mode, set the button DisplayName property:

     

    If(FormName.DisplayMode=DisplayMode.View,DisplayMode.Disabled,DisplayMode.Edit)

     

    Sik

  • Lefty Profile Picture
    1,625 on at

    Hi @v-siky-msft 

    If i understand you correctly, You want me to click on my form, and then see what the Item property is set to?

     

    I have it set to: 
    VarRecord

    which is a variable as my to show my selected gallery item, on the arrow of the gallery item OnSelect Property I have set it to :

    Set(VarRecord,ThisItem)

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 382 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard