Saturday, 4 July 2020

Set date value in Dynamics Portal

 var startdate = new date();

    var $submitField = $("#new_datevaluesetfield");

    //Get the display field
    var $displayField = $submitField.nextAll(".datetimepicker").children("input");

    //Get the display date format
    var dateFormat = $displayField.attr("data-date-format");

    //Set the submit field. Remember this needs to be in UTC and the format must be exact.
    $submitField.val(moment(startdate).format("YYYY-MM-DDTHH:mm:ss.0000000Z"));

    //Set the display field using the page's date format
    $displayField.val(moment(startdate).format(dateFormat));

No comments:

Post a Comment