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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Getting Wrong date Using Kendo html date picker

(0) ShareShare
ReportReport
Posted on by 155

Dear Experts,

am using Kendo Api for binding the values to the grid here my problem is am getting proper value in grid(am storing those values in appointment entity) in appointment entity am getting wrong date like it is showing previous date of selected date,

please can any one help me 

This is my Function

function DateTimeEditor(container, options) {
var fromdate;
var todate;
if (window.parent.Xrm.Page.getAttribute("pcl_fromdate").getValue() != null && window.parent.Xrm.Page.getAttribute("pcl_fromdate").getValue() != undefined) {
fromdate = window.parent.Xrm.Page.getAttribute("pcl_fromdate").getValue();
}
if (window.parent.Xrm.Page.getAttribute("pcl_todate").getValue() != null && window.parent.Xrm.Page.getAttribute("pcl_todate").getValue() != undefined) {
todate = window.parent.Xrm.Page.getAttribute("pcl_todate").getValue();
}
jQuery('<input data-text-field="formattedValue" data-value-field="value" data-bind="value:' + options.field + '"/>')
.appendTo(container).kendoDatePicker(
{
value: new Date(),
min: new Date(fromdate),
max: new Date(todate),
parseFormats: ["dd/MM/yyyy"]
}).data("kendoDateTimePicker");
}

 

regards 

shankar

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Since you are writing client side code i suggest you to set the timezone to your timezone or of the server using Options of the user:

    tutorial.programming4.us/.../Microsoft-Dynamics-CRM-2011---Setting-Personal-Options.aspx

  • Umashankar Sontela Profile Picture
    155 on at

    Thank you for your Responce Mohd Saad Akhtar,

    i have already selected time Zone still am getting same Values

    regards

    shankar

  • Community Member Profile Picture
    on at

    What values are your getting in fromdate and todate variables

  • Umashankar Sontela Profile Picture
    155 on at

    From date and to dates are two date pickers from the parent record based on from date and to date am able to filter the date values in the grid date picker

  • Community Member Profile Picture
    on at

    Share the code where you are storing the date in CRM from datepicker.

  • Umashankar Sontela Profile Picture
    155 on at

    yes sure mohad,

    1.Defining the columns to Grid

    columnArray.push(

    {

       name: "scheduledstart",

       type: "dateTime",

       required: true,

       editable: true,

       title: "Planned Date",

       width: "40px",

       editor: DateTimeEditor

    });

    2.Binding Values to Grid

    function DateTimeEditor(container, options) {

       var fromdate;

       var todate;

       if (window.parent.Xrm.Page.getAttribute("pcl_fromdate").getValue() != null && window.parent.Xrm.Page.getAttribute("pcl_fromdate").getValue() != undefined) {

           fromdate = window.parent.Xrm.Page.getAttribute("pcl_fromdate").getValue();

       }

       if (window.parent.Xrm.Page.getAttribute("pcl_todate").getValue() != null && window.parent.Xrm.Page.getAttribute("pcl_todate").getValue() != undefined) {

           todate = window.parent.Xrm.Page.getAttribute("pcl_todate").getValue();

       }

       jQuery('<input  data-text-field="formattedValue" data-value-field="value"  data-bind="value:' + options.field + '"/>')

    .appendTo(container).kendoDatePicker(

    {

       value: new Date(),

       min: new Date(fromdate),

       max: new Date(todate),

       parseFormats: ["dd/MM/yyyy"]

    }).data("kendoDateTimePicker");

    }

    3. Retrieving the Attributes from attributes from Appointment

    function RetrieveRecords() {

    debugger;

       var isplan = false;

       var travelPlanId = window.parent.Xrm.Page.data.entity.getId();

       var id = travelPlanId.replace(/\{|\}/gi, '');

       if (window.parent.Xrm.Page.getAttribute("pcl_travelplanstage").getValue() != null && window.parent.Xrm.Page.getAttribute("pcl_travelplanstage").getValue() != undefined) {

           if (window.parent.Xrm.Page.getAttribute("pcl_travelplanstage").getValue() == 0) {

               isplan = true;

           }

           else if (window.parent.Xrm.Page.getAttribute("pcl_travelplanstage").getValue() == 1) {

               isplan = false;

           }

       }

       if (travelPlanId != "") {

           var data = [];

           var req = new XMLHttpRequest();

           req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.1/appointments?$select=activityid,pcl_expectedtime,pcl_isplaned,pcl_planedhour,pcl_dealertype,pcl_multipleactivities,pcl_travelplanactivitystatus,pcl_type,_pcl_typeofdealer_value,_regardingobjectid_value,scheduledend,scheduledstart,statecode,subject&$filter=_regardingobjectid_value eq " + id + "", false);

           req.setRequestHeader("OData-MaxVersion", "4.0");

           req.setRequestHeader("OData-Version", "4.0");

           req.setRequestHeader("Accept", "application/json");

           req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

           req.setRequestHeader("Prefer", "odata.include-annotations=\"*\",odata.maxpagesize=5000");

           req.onreadystatechange = function () {

               if (this.readyState === 4) {

                   req.onreadystatechange = null;

                   if (this.status === 200) {

                       var results = JSON.parse(this.response);

                       for (var i = 0; i < results.value.length; i++) {

                           Appresults = JSON.parse(this.response);

                       }

                   } else {

                       Xrm.Utility.alertDialog(this.statusText);

                   }

               }

           };

           req.send();

         if (results.value[i].scheduledstart != null && results.value[i].scheduledstart != undefined) {

                       record.scheduledstart = results.value[i].scheduledstart.split("T")[0]; //results.value[i].scheduledstart;

                   }

    4.updating/ Creating the Record

    function updateRecord(EntityObj, entityobjectid) {

       if (window.parent.Xrm.Page.getAttribute("pcl_travelplanstage").getValue() != null && window.parent.Xrm.Page.getAttribute("pcl_travelplanstage").getValue() != undefined) {

           if (window.parent.Xrm.Page.getAttribute("pcl_travelplanstage").getValue() == 0) {

               isplan = true;

           }

           else if (window.parent.Xrm.Page.getAttribute("pcl_travelplanstage").getValue() == 1) {

               isplan = false;

           }

       }

       if (isplan == true) {

          if (EntityObj.data.scheduledstart != null && EntityObj.data.scheduledstart != undefined) {

                       var start = new Date(EntityObj.data.scheduledstart);

                       startdate = new Date(start.getFullYear(), start.getMonth(), start.getDate(), parseInt(data[0]), parseInt(data[1]), 0, 0);

                       if (EntityObj.data.pcl_planedhour != null && EntityObj.data.pcl_planedhour != undefined) {

                           updateRecord.attributes["pcl_planedhour"] = {

                               formattedValue: EntityObj.data.pcl_planedhour.formattedValue,

                               value: EntityObj.data.pcl_planedhour.value,

                               type: 'OptionSetValue'

                           }

                           enddate = new Date(start.getFullYear(), start.getMonth(), start.getDate(), parseInt(data[0]) + parseInt(EntityObj.data.pcl_planedhour.formattedValue), parseInt(data[1]), 0, 0);

                       }

                       updateRecord.attributes["scheduledstart"] = startdate;

                       updateRecord.attributes["scheduledend"] = enddate;

                   }

               }

    Can you please help on this

    Regards

    Shankar

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans