using javascript Archives - Microsoft Dynamics 365 Blog http://microsoftdynamics.in/category/using-javascript/ Microsoft Dynamics CRM . Microsoft Power Platform Fri, 11 Mar 2016 10:01:00 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.5 https://i0.wp.com/microsoftdynamics.in/wp-content/uploads/2020/04/cropped-Microsoftdynamics365-blogs.png?fit=32%2C32 using javascript Archives - Microsoft Dynamics 365 Blog http://microsoftdynamics.in/category/using-javascript/ 32 32 176351444 Set only contact entity or only Account entity customer field lookup in case / Opportunity for ms crm http://microsoftdynamics.in/2016/03/11/set-only-contact-entity-or-only-account-entity-customer-field-lookup-in-case-opportunity-for-ms-crm/ Fri, 11 Mar 2016 10:01:00 +0000 http://microsoftdynamics.in/2016/03/11/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...

The post Set only contact entity or only Account entity customer field lookup in case / Opportunity for ms crm appeared first on Microsoft Dynamics 365 Blog.

]]>

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 

Only Contact records are views
Only Contact is selected and read only

Both account and contact shown by default 
function disableaccountfromcustomer() {
debugger;
//timeout of 1sec
    setTimeout(function () {
debugger;
        var getid = $(‘#customerid_i’); //customer field id contain account and contact both view
        getid .attr(‘defaulttype’, ‘2’); // default advance find entity type to contact
        getid .attr(‘lookuptypes’, ‘2’); //change lookup view to contact
    }, 1000);

}

SOURCE : JUST2CODE.IN Subscribe to our YouTube channel : https://www.youtube.com/user/TheRussell2012

The post Set only contact entity or only Account entity customer field lookup in case / Opportunity for ms crm appeared first on Microsoft Dynamics 365 Blog.

]]>
2784
Set Profile Image / note attachment using javascript / jquery in mscrm http://microsoftdynamics.in/2015/09/01/set-profile-image-note-attachment-using-javascript-jquery-in-mscrm/ Tue, 01 Sep 2015 12:52:00 +0000 http://microsoftdynamics.in/2015/09/01/set-profile-image-note-attachment-using-javascript-jquery-in-mscrm/ Below code convert image from upload control and convert it into base64 which can be directly set to the image field / notes etc ,  function uploadprofilepic(){      var imgvar = new Image();         imgvar.src = SourceOfFile;         imgvar.onload = function () {          ...

The post Set Profile Image / note attachment using javascript / jquery in mscrm appeared first on Microsoft Dynamics 365 Blog.

]]>
Below code convert image from upload control and convert it into base64 which can be directly set to the image field / notes etc ,

 function uploadprofilepic(){
     var imgvar = new Image();
        imgvar.src = SourceOfFile;
        imgvar.onload = function () {              
         var canvas = document.createElement(“canvas”);
         canvas.width = this.width;
         canvas.height = this.height;
     
         var ctx = canvas.getContext(“2d”);
         ctx.drawImage(this, 0, 0);
         var dataURL = canvas.toDataURL(“image/png”);
      var base64Image = dataURL.replace(/^data:image/(png|jpg);base64,/, “”);
Now This base64Image can be set Directly to Imageprofile of an entity .
entityimage = base64Image ;
Hope this Helped Thanks for the Support .


SOURCE : JUST2CODE.IN Subscribe to our YouTube channel : https://www.youtube.com/user/TheRussell2012

The post Set Profile Image / note attachment using javascript / jquery in mscrm appeared first on Microsoft Dynamics 365 Blog.

]]>
2792
Convert Image file to stream / base64Image using javascript / jquery . http://microsoftdynamics.in/2015/09/01/convert-image-file-to-stream-base64image-using-javascript-jquery/ Tue, 01 Sep 2015 12:00:00 +0000 http://microsoftdynamics.in/2015/09/01/convert-image-file-to-stream-base64image-using-javascript-jquery/ Below Code convert the image file to base64 which can be used to compare image etc .  var imgvar = new Image();         imgvar.src = SourceOfFile;         imgvar.onload = function () {                        var canvas = document.createElement(“canvas”);    ...

The post Convert Image file to stream / base64Image using javascript / jquery . appeared first on Microsoft Dynamics 365 Blog.

]]>
Below Code convert the image file to base64 which can be used to compare image etc .

 var imgvar = new Image();
        imgvar.src = SourceOfFile;
        imgvar.onload = function () {              
         var canvas = document.createElement(“canvas”);
         canvas.width = this.width;
         canvas.height = this.height;
     
         var ctx = canvas.getContext(“2d”);
         ctx.drawImage(this, 0, 0);
         var dataURL = canvas.toDataURL(“image/png”);
      var base64Image = dataURL.replace(/^data:image/(png|jpg);base64,/, “”);
Thanks

SOURCE : JUST2CODE.IN Subscribe to our YouTube channel : https://www.youtube.com/user/TheRussell2012

The post Convert Image file to stream / base64Image using javascript / jquery . appeared first on Microsoft Dynamics 365 Blog.

]]>
2794
Get Server URL or IP using JavaScript in MSCRM 2011 , MSCRM 2013 , MSCRM 2015 http://microsoftdynamics.in/2015/06/10/get-server-url-or-ip-using-javascript-in-mscrm-2011-mscrm-2013-mscrm-2015/ Wed, 10 Jun 2015 12:55:00 +0000 http://microsoftdynamics.in/2015/06/10/get-server-url-or-ip-using-javascript-in-mscrm-2011-mscrm-2013-mscrm-2015/ Some time we need to get server IP  instead of Server URL Like when we need to write Odata Query in dev and frequently sift Solution from dev to production , it imp to get Ip dynamically so , you Odata don’t give error . // Simple Server Url using JavaScript var serverUrl = Xrm.Page.context.getServerUrl();...

The post Get Server URL or IP using JavaScript in MSCRM 2011 , MSCRM 2013 , MSCRM 2015 appeared first on Microsoft Dynamics 365 Blog.

]]>
Some time we need to get server IP  instead of Server URL Like when we need to write Odata Query in dev and frequently sift Solution from dev to production , it imp to get Ip dynamically so , you Odata don’t give error .
// Simple Server Url using JavaScript
var serverUrl = Xrm.Page.context.getServerUrl();
//Work fine for both IP And server

var serverUrl = document.location.protocol + “//” + document.location.host + “/” + Xrm.Page.context.getOrgUniqueName();

This Above code will work fine for both Server IP or Url as when we access mscrm record with only server name ( but our odata code contain ip it will throw an exception ) or if we access with IP ans our code contain server url so to prevent this we can use above code to get dynamic URL address.

SOURCE : JUST2CODE.IN Subscribe to our YouTube channel : https://www.youtube.com/user/TheRussell2012

The post Get Server URL or IP using JavaScript in MSCRM 2011 , MSCRM 2013 , MSCRM 2015 appeared first on Microsoft Dynamics 365 Blog.

]]>
2797
Get Difference in days between two date fields using javascript ( differences between dates ) http://microsoftdynamics.in/2015/03/12/get-difference-in-days-between-two-date-fields-using-javascript-differences-between-dates/ http://microsoftdynamics.in/2015/03/12/get-difference-in-days-between-two-date-fields-using-javascript-differences-between-dates/#comments Thu, 12 Mar 2015 08:01:00 +0000 http://microsoftdynamics.in/2015/03/12/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...

The post Get Difference in days between two date fields using javascript ( differences between dates ) appeared first on Microsoft Dynamics 365 Blog.

]]>
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 : https://www.youtube.com/user/TheRussell2012

The post Get Difference in days between two date fields using javascript ( differences between dates ) appeared first on Microsoft Dynamics 365 Blog.

]]>
http://microsoftdynamics.in/2015/03/12/get-difference-in-days-between-two-date-fields-using-javascript-differences-between-dates/feed/ 2 2798
Set Field Read Only Using JavaScript In MSCRM ( Lock Field in MS CRM ) http://microsoftdynamics.in/2015/02/20/set-field-read-only-using-javascript-in-mscrm-lock-field-in-ms-crm/ Fri, 20 Feb 2015 10:19:00 +0000 http://microsoftdynamics.in/2015/02/20/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 Xrm.Page.ui.controls.get(“new_companyreference”); // Now set the property to lock the field ToBeReadOnlyControl.setDisabled(true); Note : Xrm.Page.ui.controls.get(“new_companyreference”); by this we get full UI controls of the attribute / field by which we...

The post Set Field Read Only Using JavaScript In MSCRM ( Lock Field in MS CRM ) appeared first on Microsoft Dynamics 365 Blog.

]]>

Hey Below is the Code To Set a Attribute / field on form Read only (Lock) using JavaScript in MS CRM .
// Get Control of entity
Xrm.Page.ui.controls.get(“new_companyreference”);
// Now set the property to lock the field

ToBeReadOnlyControl.setDisabled(true);
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 : https://www.youtube.com/user/TheRussell2012

The post Set Field Read Only Using JavaScript In MSCRM ( Lock Field in MS CRM ) appeared first on Microsoft Dynamics 365 Blog.

]]>
2801
Get Entity Name Using JavaScript in ms crm 2011 , ms crm 2013 , ms crm 2015 ( get dynamically Entity Name using Javascript) http://microsoftdynamics.in/2015/02/19/get-entity-name-using-javascript-in-ms-crm-2011-ms-crm-2013-ms-crm-2015-get-dynamically-entity-name-using-javascript/ Thu, 19 Feb 2015 12:51:00 +0000 http://microsoftdynamics.in/2015/02/19/get-entity-name-using-javascript-in-ms-crm-2011-ms-crm-2013-ms-crm-2015-get-dynamically-entity-name-using-javascript/ Below is the Code for Fetching Name of an Entity Using JavaScript In mscrm , Which can be used for many purposes  Like if you want to popup an new entity form ( you can create a generic function ) var entityName = Xrm.Page.data.entity.getEntityName(); // Pop Up example var id = Xrm.Page.data.entity.getId(); var entityName =...

The post Get Entity Name Using JavaScript in ms crm 2011 , ms crm 2013 , ms crm 2015 ( get dynamically Entity Name using Javascript) appeared first on Microsoft Dynamics 365 Blog.

]]>

Below is the Code for Fetching Name of an Entity Using JavaScript In mscrm , Which can be used for many purposes  Like if you want to popup an new entity form ( you can create a generic function )
 var entityName = Xrm.Page.data.entity.getEntityName();
// Pop Up example
 var id = Xrm.Page.data.entity.getId();
var entityName = Xrm.Page.data.entity.getEntityName();
Xrm.Utility.openEntityForm(entityName, id);


Hope This Helps You Thanks.

SOURCE : JUST2CODE.IN Subscribe to our YouTube channel : https://www.youtube.com/user/TheRussell2012

The post Get Entity Name Using JavaScript in ms crm 2011 , ms crm 2013 , ms crm 2015 ( get dynamically Entity Name using Javascript) appeared first on Microsoft Dynamics 365 Blog.

]]>
2802