Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Auto populate date field with Current date

Posted on by

Is there a way to get a date field to autopopulate with the current date without having to use code?

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Auto populate date field with Current date

    Hi

    You can try the following code plz change the schema name and write the js onChange event on form properties

    function test()

    {

      var _ContractStartDate = Xrm.Page.getAttribute("new_contractstartdate").getValue();

      if (Xrm.Page.getAttribute("new_contractstartdate") != null) {

          var ContractStartDate = new Date(_ContractStartDate.getMonth() + 1 + "/10/" + _ContractStartDate.getFullYear())

          Xrm.Page.getAttribute('new_contractstartdate').setValue(ContractStartDate);

      }

      else {

          Xrm.Page.getAttribute('new_contractstartdate').setValue(null);

      }

    }

    Thanks,

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Auto populate date field with Current date

    On schema name - "suc_paymentduedate" fieldname - PaymentDueDate on the Main form i need to do.. i had to create the field it was not created...

    Thanks

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Auto populate date field with Current date

    I am asking about attribute in which you want to show date

    (like this every month the date of that particular field will change the month but date will remain 10th).

    Is this field created by you?

    Thanks

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Auto populate date field with Current date

    Hi Ridhima,

    The form is Main form type, if that is what you asked was, am new to CRM....sorry may be I am sounding funny :(

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Auto populate date field with Current date

    Hi Sucharita.

    Are you using custom field of date and time type?

    Thanks

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Auto populate date field with Current date

    i want a field to show date 10th day of month. Suppose it is April then it should show 10 April 2018 or 10/04/2018 like this every month the date of that particular field will change the month but date will remain 10th, how to do using javascript on CRM form. Can you please help???

  • iruser2 Profile Picture
    iruser2 2,046 on at
    RE: Auto populate date field with Current date

    does real time work flow on creation of..... mean I have to click save?

    I would love to have a date field that autopopulates as today as the form opens.  Not as the form saves.

    thanks!

  • Suggested answer
    Patrick Grootaarts Profile Picture
    Patrick Grootaarts 560 on at
    RE: Auto populate date field with Current date

    Allready found the solution by a small script:

    function updateDateField(startdate) {

    var currentDateTime = new Date();

    Xrm.Page.getAttribute(startdate).setValue(currentDateTime);

    }

  • Patrick Grootaarts Profile Picture
    Patrick Grootaarts 560 on at
    RE: Auto populate date field with Current date

    Hi Karth, this is something that runs in the background am I right? What do I need to do if I want to have the date predefined on the form. So a default value (data of today) and I can adjust it later and then save the form?

  • Suggested answer
    Karth Profile Picture
    Karth on at
    RE: Auto populate date field with Current date

    For the records already created, you can follow the same approach, but using the on-demand workflows. You can then select the records through Advanced Find, and run the on-demand workflow.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans