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));

Friday, 3 July 2020

Dynamics CRM Portals


Lookup field disabled.       

  $("#transactioncurrencyid_enityname").prop("disabled", true);
            $("#transactioncurrencyid_entityname").parent().find('.launchentitylookup').prop("disabled", true);
            $("#transactioncurrencyid_entityname").parent().find('.clearlookupfield').prop("disabled", true);


Date field:


  $('#new_starttimedate_datepicker_description').val(null);

$('#date').next().children().prop("readonly", true);

    $("#new_requesttype option:not(:selected)").prop("disabled", true);



 $.ajax({
            url: "",
        }).fail(function (jqXHR, textStatus, error) { })
            .done(function (result) {
                if (result != null) {
                    var dropdown = $("#new_fieldname");
                    dropdown.empty();
                    var optionArray = [];
                    $.each(result, function (index, options) {
                        var option = $('<option>').text(options.new_name).val(options.gs_lookupid);
                        optionArray.push(option);
                    });
                    $("#new_fieldname").html(optionArray);
                    dropdown[0].selectedIndex = -1;
                }

            });