Setting Datetime field in MS CRM 2011


If you want to set a datatime field in MS CRM 2011, you can follow below code for the same

//Set current Datetime field in Javascript

var _D=new Date();

   Xrm.Page.getAttribute(‘fieldname’).setValue(_D);

 //Set Current datetime in Server side code

DateTime _CurrentDate=DateTime.Now;

_EntityObject[“AttributeName”]=_CurrentDate;

 //Set retrieved date using Rest

var  _DateVal = dateReviver(Resultset.DateAttribute); //dateReviver is a function to format date

 Xrm.Page.getAttribute(“targeAttributeName”).setValue(_DateVal);

Enjoy!!!

Advertisements

Leave a comment

Filed under MS CRM 2011

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s