cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ewoud
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
BenFetters
Continued Contributor
Continued Contributor

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
BenFetters
Continued Contributor
Continued Contributor

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

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

BenFetters
Continued Contributor
Continued Contributor

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (53,728)