cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ewoud
Level: Powered On

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
BenFetters
Level 8

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 new 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

View solution in original post

3 REPLIES 3
BenFetters
Level 8

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 new 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

View solution in original post

Ewoud
Level: Powered On

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
BenFetters
Level 8

Re: Only show current date when item is created

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

 

Kind regards,

Ben

Helpful resources

Announcements
thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,950)