web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Auto fill date time on entity

(0) ShareShare
ReportReport
Posted on by

Hello there i have a function to auto fill date time Like owner field when create new record below is code 

but not working where i am wrong 2013 crm

function InitiateDate()
{

var isCreateForm =Xrm.Page.ui.getFormType() ==1;
var vardate = Xrm.Page.getAttribute(‘new_datetime’).getValue();
if(isCreateForm)
{
vardate .setValue(new Date());
vardate .setSubmitMode("always");

}

}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Rajkumar Rajaraman Profile Picture
    on at
    RE: Auto fill date time on entity

    Hi Sibtain,

    Refer the following blog:

    www.magnetismsolutions.com/.../Prefill_a_Date_Field_with_Today_s_Date_in_Dynamics_CRM_2011.aspx

    Also pass the name of the field in parameter in the handler properties.

    Regards,

    R.Rajkumar

    "Please mark my answer as verified if you found it helpful"

  • Community Member Profile Picture
    on at
    RE: Auto fill date time on entity

    Hello  Rajkumar

    the parameter date in SetToday(date ) functin is field name ??

    function setToday(date) {

       var isCreateForm = Xrm.Page.ui.getFormType() == 1;

       var dateField = Xrm.Page.getAttribute(date);

       if (isCreateForm) { // Check that this is a new Record

           dateField.setValue(new Date()); // Set the Date field to Today

           dateField.setSubmitMode("always"); // Save Disabled Fields

       }

    }

  • Suggested answer
    Rajkumar Rajaraman Profile Picture
    on at
    RE: Auto fill date time on entity

    Hi Sibtain,

    No. In your CRM Form Date time Field.

    I think in yours as "new_datetime".

    Hope this helps.

    Regards,

    R.Rajkumar

    "Please mark my answer as verified if you found it helpful"

  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at
    RE: Auto fill date time on entity

    Hello,

    Change your code like below

    function InitiateDate()

    {

    var isCreateForm =Xrm.Page.ui.getFormType() ==1;

    var vardate = Xrm.Page.getAttribute('new_datetime');

    if(isCreateForm)

    {

    vardate.setValue(new Date());

    vardate.setSubmitMode("always");

    }

    }

    Thanks

  • Community Member Profile Picture
    on at
    RE: Auto fill date time on entity

    Done it ;)  thanks

  • Rajkumar Rajaraman Profile Picture
    on at
    RE: Auto fill date time on entity

    Hi Sibtain,

    Please mark my answer as verified if you found it helpful

  • Jharana Baliyar Singh Profile Picture
    2,667 on at
    RE: Auto fill date time on entity

    Hi Sibtain,

    Please follow the below link it may helps out.

    kbase.icbconsulting.com/.../javascript-to-default-a-date-time-field-with-today-s-date

    Thanks,

    Jharana B.Singh

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans