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!!!

Leave a comment

Filed under MS CRM 2011

Leave a comment