My Photo

Microsoft Dynamics 365

Official Blog for Microsoft Dynamics Functional and Technical Solutions....
Browsing Category " using javascript "

Set only contact entity or only Account entity customer field lookup in case / Opportunity for ms crm

Set potential customer look up field to only for contact entity record.

By default out of the box functionality gave a pop up with two entity type -contact & account for customer lookup field ,
if your requirement is to set only contact or only account as entity it can be done using javascript as given below ,

Both Contact and Account are viewed by Default 

Get Difference in days between two date fields using javascript ( differences between dates )

Hello , below you will find function calculating difference in days between two field using java script .

function diffrenceindays() {
    var startdate = GetDateValue(startfield);
    var Enddate = GetDateValue(endfield);

    var oneday = 1000 * 60 * 60 * 24;
    var differenceInDays = ((Enddate - startdate) / oneday);
    if (differenceInDays < 0) {
        alert(" date cannot be less then start date");

    alert(" diffrence in days  " + differenceInDays);


function GetDateValue(field) {

    var year = field.getFullYear();
    var month = field.getMonth();
    var day = field.getDate();
    dateOnly = new Date(year, month, day);
    return dateOnly;


SOURCE : JUST2CODE.IN Subscribe to our YouTube channel :

Set Field Read Only Using JavaScript In MSCRM ( Lock Field in MS CRM )

Hey Below is the Code To Set a Attribute / field on form Read only (Lock) using JavaScript in MS CRM .

// Get Control of entity
// Now set the property to lock the field

Note : Xrm.Page.ui.controls.get("new_companyreference"); by this we get full UI controls of the attribute / field by which we can set or get any ui property of that field .

SOURCE : JUST2CODE.IN Subscribe to our YouTube channel :