cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

Only show current date when item is created

Hi there,

I have created a form for onboarding. One of the fields is the date of onboarding. I have the default date set to Today() so it shows today's date. When someone is filling in the form and changes the date to a different date it saves the new date nicely into the SharePoint item. But when the form is opened again, the date is changed back to today. What I want is that Today() is only used when the item is created but once the item is created it should not use Today() anymore but respect the entered date.

Same goes for other date fields that I have in the form and those dates are based on the Onboarding date. For example I am using:

DateAdd(DataCardValue5.SelectedDate; 0; Days)

DateAdd(DataCardValue5.SelectedDate; 30; Days)

They also are being set back to default when the newly created item is opened again.

today.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Continued Contributor
Continued Contributor

Re: Only show current date when item is created

Hi,

I have run into this problem as well. When you have a custome form from SharePoint, you have to be careful when you're changing the default because it's always going to show the default. With normal apps the form will automatically switch between the default value when it's new and the value when you're looking at an item. When you do the custom form, you have to sort of tell it what mode the form is in (New, View, Edit) and what to show. 


To solve this, in your default date property, try this formula:

If(SharePointForm1.Mode = FormMode.New, Today(),Parent.Default)

 

This says that if the form is in new mode, have it be today. If not (if your form is in view or edit mode), have it be the item's date that you selected in your SharePoint list. I hope that helps.

 

Let me know if any of that didn't make sense at all though! 

 

Kind regards,

Ben

If this solved the problem for you, feel free to hit "Accept as Solution" so others can find the answer easier. 🙂

Kind regards,

Ben Fetters
Power Apps/Power Automate Developer
www.sovereignsp.com

View solution in original post

3 REPLIES 3
Highlighted
Continued Contributor
Continued Contributor

Re: Only show current date when item is created

Hi,

I have run into this problem as well. When you have a custome form from SharePoint, you have to be careful when you're changing the default because it's always going to show the default. With normal apps the form will automatically switch between the default value when it's new and the value when you're looking at an item. When you do the custom form, you have to sort of tell it what mode the form is in (New, View, Edit) and what to show. 


To solve this, in your default date property, try this formula:

If(SharePointForm1.Mode = FormMode.New, Today(),Parent.Default)

 

This says that if the form is in new mode, have it be today. If not (if your form is in view or edit mode), have it be the item's date that you selected in your SharePoint list. I hope that helps.

 

Let me know if any of that didn't make sense at all though! 

 

Kind regards,

Ben

If this solved the problem for you, feel free to hit "Accept as Solution" so others can find the answer easier. 🙂

Kind regards,

Ben Fetters
Power Apps/Power Automate Developer
www.sovereignsp.com

View solution in original post

Highlighted
Helper III
Helper III

Re: Only show current date when item is created

Hi @BenFetters,

Thanks for your reply. I had to make a small change to make it work:

If(SharePointForm1.Mode = FormMode.New; Today();Parent.Default)

So I changed the comma's to semicolons.

Based on this I was also able to change the other functions:

If(SharePointForm1.Mode = FormMode.New; DateAdd(DataCardValue5.SelectedDate; 0; Days); Parent.Default)

If(SharePointForm1.Mode = FormMode.New; DateAdd(DataCardValue5.SelectedDate; 30; Days); Parent.Default)

Maybe this will help others who need something similar.

Again thank you for your help.

Regards Ewoud

Highlighted
Continued Contributor
Continued Contributor

Re: Only show current date when item is created

Oh awesome! That's great. And I'm glad I could help! 

 

Kind regards,

Ben

If this solved the problem for you, feel free to hit "Accept as Solution" so others can find the answer easier. 🙂

Kind regards,

Ben Fetters
Power Apps/Power Automate Developer
www.sovereignsp.com

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (7,350)