cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
skolisetti
Helper IV
Helper IV

How to set date column with default date

Hello,

 

Is there any way to set the "Date column" with todays date always. When the form is loaded ?

 

PFA

 

 

2 REPLIES 2
dpoggemann
Super User
Super User

Hi @skolisetti ,

 

Please see the following (https://powerusers.microsoft.com/t5/Microsoft-Dataverse/Default-Dates-in-Model-Driven-App-forms/td-p...) as this would need to be done with JavaScript.

 

Hope this helps.  Please accept if answers your question or Like if helps in any way.


Thanks,


Drew

 

 

Hope this helps. Please accept if answers your question or Like if helps in any way.
Thanks,
Drew
rampprakash
Super User
Super User

Hello @skolisetti,

 

You can use below code

 

1. Login to https://make.powerapps.com

2. Expand Tables

3. Open the Form from the required Table

4. Then Click on Events --> Select OnLoad--> then Select New WebResource --> Create a WebResoure--> Paste the code which i mentioned

5. Then in onLoad Operation set the Function as SetToday make sure you selected Execution Context checkbox is selected

6. Save and Close then Publish

 

function SetToday(executionContext) {
var formContext = executionContext.getFormContext();
if (formContext.ui.getFormType() == 1) {
formContext.getAttribute(FIELDLOGICALNAME).setValue(new Date()); // new Date is for Setting current Date
formContext.getAttribute(FIELDLOGICALNAME).setSubmitMode("always"); // if field is disabled we can use Always to set the value
}
}

 

Please mark as Answer if it is helpful and provide Kudos


Subscribe : https://www.youtube.com/channel/UCnGNN3hdlKBOr6PXotskNLA
Blog : https://microsoftcrmtechie.blogspot.com

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Users online (5,568)