JavaScript/ Jquery Reference for Microsoft Dynamics CRM Portal (formerly AdxStudio)


//Get value of field from current page
var name = $('#new_name').val();
//Find the checkbox value
$('#new_arepartsreplaced').is(":checked");
//Get value of field from parent page
var WorkOrder = $('#msdyn_name'window.parent.document)[0].value;
//Get record id from url of parent page
var WOId = window.parent.location.href.substr(window.parent.location.href.indexOf("?id"+ 4);
//Get Picklist value from parent page
var Status = $($('#new_status'window.parent.document)[0]).find("option:selected").prop("value");
//Disable DateTime Field
$("#msdyn_timetopromised_description").parent().find('.form-control').prop('disabled'true);
$("#msdyn_timetopromised").parent().find('.input-group-addon').hide();
//Disable Lookup
$("#new_workorder").prop('disabled'true);
$("#new_workorder_name").parent().find('.input-group-btn').hide();
//Disable a field
$("#new_visitforcv").prop('disabled'true);
//Disable all fields on form
$("form").each(function () {
    $(this).find(':input').not('[type=hidden]').not('[class=close]').prop('disabled'true);
});
//Hide field row
$("#new_dealerofferproductguid").closest("tr").hide();
//Hide DateTime
$('#endtime_label').hide();
$('input[aria-describedby="endtime_description"]').parent().parent().hide();
//Hide Text Fields
$('#new_uptimewarrantyrequired_label').hide();
$("#new_uptimewarrantyrequired").hide();
//Hide Lookup Field
$('#new_assigntoteam_label').hide();
$('#new_assigntoteam_name').hide();
$("#new_assigntoteam_name").parent().find('.input-group-btn').hide();
//Clear Text field
$("#new_delayduetocustomerreason").val(null);
//Clear Date field value
$("#new_ddcenddate").datepicker({ dateFormat: 'dd,MM,yyyy' }).val('');
//set text field value
$('#new_name').val("aayush signh");
//Get Set lookup field value
var lookupId = $("#new_address1state").val();
var lookupName = $("#new_address1state_name").val();
var entityName = $("#new_address1state_entityname").val();
$("#new_address2state").val(lookupId);
$("#new_address2state_name").val(lookupName);
$("#new_address2state_entityname").val(entityName);
//Setdatetime
function setDateTime() {
    var roundTripFormat = "yyyy-MM-ddTHH:mm:ss.0000000\\Z";
    var a = new Date(); //new Date(starttime);
    a = a.addHours(-5);
    a = a.addMinutes(-30);
    a = new Date(moment(a).utc());
    var formatteddate = a.format(roundTripFormat);
    var date = getdatetime(new Date());
    $("#msdyn_timetopromised").datepicker({ dateFormat: 'dd,MM,yyyy' }).val(formatteddate);  // Actual value passing to crm
    $('input[aria-describedby="msdyn_timetopromised_description"]').val(date);  // For Display only on date field control
}
//Add Business Required Class
$("#new_amquotetemplate_label").parent().addClass("required");
//Remove Business Required Class
$("#new_amquotetemplate_label").parent().removeClass("required");
function getdatetime(dt) {
    var res = "";
    res += dt.getMonth() + 1;
    res += "/";
    res += dt.getDate();
    res += "/";
    res += dt.getFullYear();
    res += " ";
    res += dt.getHours() > 12 ? dt.getHours() - 12 : dt.getHours();
    res += ":";
    res += formatdigits(dt.getMinutes());
    res += " " + dt.getHours() > 11 ? " PM" : " AM";
    return res;
}
function formatdigits(val) {
    val = val.toString();
    return val.length == 1 ? "0" + val : val;
}
//Change label text on load of form
$(document).ready(function () {
    $('#new_name_label').text("Please enter customer's full name");
});
//Hide Section
$('table[data-name="tab_16_section_1"]').closest('fieldset').hide();
//Show Section
$('table[data-name="tab_16_section_1"]').closest('fieldset').show();
//Hide option from Picklist
$("#new_status option[value='100000002']").hide();
//Clear Picklist Options
$("#new_status option").remove();
//Add Options in Picklist
$('#new_status').append($('<option>', { value: "10000001", text: "Option-1" }));
//Get the selected picklist Text value
$("#msdyn_workordertype option:selected").text();
//Append blank value to a picklist
$("#new_product").prepend("<option value=''></option>");
//set Picklist value by text
$('#new_status option:contains("' + StatusName + '")').attr("selected""selected");
//Hide Tab
function HideTab(sectionname) {
    var tab = $('table[data-name="' + sectionname + '"]').closest('.tab');
    var label = tab.prev('.tab-title');
    tab.hide();
    label.hide();
}
//Show tab
function Showtab(sectionname) {
    var tab = $('table[data-name="' + sectionname + '"]').closest('.tab');
    var label = tab.prev('.tab-title');
    tab.show();
    label.show();
}
//Hide button based on class name
var x = $(this).context.getElementsByClassName("workflow-link btn-default btn");
var i;
for (i = 0; i < x.length; i++) {
    x[i].style.display = "none";
}
//Get Today-x days date value
var BackDate = new Date(Date.parse(new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() - 3)));

Comments

Popular posts from this blog

Search data in Gridview on Textbox Key press event using JQuery in Asp.Net- C#

StateCode and StatusCode Values for mostly used entities in Microsoft Dynamics CRM 2013

Dumps for Microsoft Dynamics CRM MB2-703 Practice Exam Questions Free

How to import CSV files into DataTable in C#

How to show enlarge image when mouse hover on image or link in Asp.Net(c#) using JavaScript

go to top image