cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

Setting Open and Close Date

I need to be able to set a closing date for a power app form connected to a Sharepoint list.  It needs to go to a different Screen saying this form is closed after that date but not sure how to do it.

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Community Champion
Community Champion

Re: Setting Open and Close Date

HI @bnething ,

I will answer both questions. If you wanted the hard-code the date, use this syntax (replace with actual date)

Set(vExpiry,DateValue("mm/dd/yyyy"))

You could do this at App OnStart.
If you wanted to put this on a single-line SharePoint reference list (I do a few of these) assuming it is called RefList, the ID is 1 and the field is RefDate, you would do the same with a Lookup

Set(
   vExpiry,
   Lookup(
      RefList,
      ID=1,
      RefDate
   )
)

To answer your second question - this would give the user a View form on the current record, otherwise a New form if on or before the expiry date.

If(
   vExpiry<Today(),
   ViewForm(YourFormName),
   NewForm(YourFormName)
)

If the form is on another screen, add Navigate to this.

 

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.

View solution in original post

Highlighted
Community Champion
Community Champion

Re: Setting Open and Close Date

Hi @bnething ,

By date/time stamp on screenshots - also AEST? Central Queensland here.

The bit of information I was missing was that this is a SharePoint Integration form (not a standalone app) - a bit more of a challenge here, but I hope achievable.

Leave the App OnStart as it is and put this in the SharePoint Integration OnNew code

If(
   vExpiry<Today(),
   ViewForm(SharePointForm1),
   NewForm(SharePointForm1)
)

This should work.

 

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.

View solution in original post

11 REPLIES 11
Highlighted
Community Champion
Community Champion

Re: Setting Open and Close Date

Hi @bnething ,

Are you wanting to write this date to a list and is the date the current date (today)?

Highlighted
Regular Visitor

Re: Setting Open and Close Date

Hi Warren.  What I am wanting to have happen is that if a user links to a form (list) and tries to create a new item that is past a certain date then the form automatically goes to a form closed view.  I know you can do it in Infopath but I can't see anyone who has done a how to with a power app form.  I'm no coder and I've been going around in circles for a day now.  

 

Regards

 

Brett

Highlighted
Community Champion
Community Champion

Re: Setting Open and Close Date

OK @bnething ,

Are you wanting to hard-code this or get it from a reference list?

Either way, set the date to a Variable (I will call it vExpiry) and test for this on the New Record icon

If(
   vExpiry<Today(),
   Notify("No new records are able to be entered",NotificationType.Error),
   NewForm(YourFormName)
)

This way they cannot get to the new record form.

 

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.

Highlighted
Regular Visitor

Re: Setting Open and Close Date

Hi Warren.  Thanks for this.  Nearly there I think.  If I wanted the user to be presented with another view of the form explaining that the dates are closed is that possible rather than just preventing them from opening it?

 

Highlighted
Regular Visitor

Re: Setting Open and Close Date

And may I ask how do I set a date to a variable?  Sorry I'm a designer so this is all rather foreign to me. 

Highlighted
Community Champion
Community Champion

Re: Setting Open and Close Date

HI @bnething ,

I will answer both questions. If you wanted the hard-code the date, use this syntax (replace with actual date)

Set(vExpiry,DateValue("mm/dd/yyyy"))

You could do this at App OnStart.
If you wanted to put this on a single-line SharePoint reference list (I do a few of these) assuming it is called RefList, the ID is 1 and the field is RefDate, you would do the same with a Lookup

Set(
   vExpiry,
   Lookup(
      RefList,
      ID=1,
      RefDate
   )
)

To answer your second question - this would give the user a View form on the current record, otherwise a New form if on or before the expiry date.

If(
   vExpiry<Today(),
   ViewForm(YourFormName),
   NewForm(YourFormName)
)

If the form is on another screen, add Navigate to this.

 

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.

View solution in original post

Highlighted
Regular Visitor

Re: Setting Open and Close Date

Ok I think I've done what your suggesting but It is still remaining on the form screen, see screen grabs.  Whilst on the topic is there a way to create a new item where it doesn't pre populate it with the first record? I would assume this would a Newform on the App on new somehow?

 

Thanks for your help so far, I really do appreciate it.

Highlighted
Community Champion
Community Champion

Re: Setting Open and Close Date

Hi @bnething ,

By date/time stamp on screenshots - also AEST? Central Queensland here.

The bit of information I was missing was that this is a SharePoint Integration form (not a standalone app) - a bit more of a challenge here, but I hope achievable.

Leave the App OnStart as it is and put this in the SharePoint Integration OnNew code

If(
   vExpiry<Today(),
   ViewForm(SharePointForm1),
   NewForm(SharePointForm1)
)

This should work.

 

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.

View solution in original post

Highlighted
Regular Visitor

Re: Setting Open and Close Date

I figured it out by putting:

 

If( vExpiry<Today(), Navigate(Expired) )

 

Where "Expired" is the name of the screen with the details of the form now being closed.

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

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