How to Get the value from a CRM field

// JavaScript/JScript in CRM 2011 | CRM 2011 Training Series     //How to Get the value from a CRM field     var varMyValue = Xrm.Page.getAttribute(“CRMFieldSchemaName”).getValue() ; //How to Set the value of a CRM field Xrm.Page.getAttribute(“po_CRMFieldSchemaName”).setValue('My New Value');  **For CRM 2011 Training, please check out our CRM Training page. Please share |Like in Facebook if…

How to get Form Type using JavaScript in CRM 2011

  Get Form type using javascript in CRM 2011 : When you write Java script/Jscript code on CRM forms, there will be situations where you need to trigger the script only on certain forms. This is how we get the Form Type. In CRM 2011, there are 7 types of forms are defined. 0 -…

How to Get the label of the control using Javascript?

// JavaScript/JScript in CRM 2011 | CRM 2011 Training Series // How to Get the label of the control using Javascript?     Xrm.Page.ui.controls.get('<Attribute Name>').getLabel()     // Get record id     Xrm.Page.data.entity.getId()     // set field as required based value of a check box field.     function OnChangeBoolField()     {     var varBool = Xrm.Page.data.entity.attributes.get("<Boolean Field…

How to retieve data through SOAP XML using Jscript in CRM 2011

//How to retieve data through SOAP XML using Jscript in CRM 2011 if (Xrm.Page.getAttribute("parentcustomerid").getValue() != null) {     //acount guid no     var parentcustomerID = Xrm.Page.data.entity.attributes.get("parentcustomerid").getValue()[0].id;     var xml = "<?xml version='1.0' encoding='utf-8'?>" +     "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'" +     " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +     " xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" +     GenerateAuthenticationHeader() +     "<soap:Body>" +     "<Retrieve xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"…

How to Compare Dates using JavaScript?

// How to Compare Dates using JavaScript?     function ValidateDates()     {     var Date1 = Xrm.Page.getAttribute('<Date Attribute Name1>').getValue();     var Date2 = Xrm.Page.getAttribute('<Date Attribute Name2>').getValue();      if(Date1 != null && Date2 != null)      {      if(Date1.setHours(0,0,0,0) < Date2.setHours(0,0,0,0))      {      alert('Date2 is greater than or equal to Date1');      }      }…

How to get the Lookup field value using JavaScript?

//How to get the Lookup field value using JavaScript?     var lookupObject = Xrm.Page.getAttribute("<lookupattributename>");     if (lookupObject != null)     {         var lookUpObjectValue = lookupObject.getValue();         if ((lookUpObjectValue != null))         {          var lookuptextvalue = lookUpObjectValue[0].name;          var lookupid = lookUpObjectValue[0].id;         }      } Please share |Like in Facebook if you feel…

How to Set a lookup value using JavaScript?

//How to Set a lookup value using JavaScript? var lookup = new Array(); lookup[0] = new Object(); lookup[0].id = recorid; lookup[0].name = recordname; lookup[0].entityType = entityname; Xrm.Page.getAttribute("attributename").setValue(lookup); //Alternate method to set lookup value Xrm.Page.getAttribute("attributename").setValue([{ id: recorid, name: recordname, entityType: entityname}]); **For CRM 2011 Training, please check out our CRM Training page. Please share |Like in…

How to Hide a section in CRM 2011 using JavaScript?

//How to Show a section using JavaScript? Xrm.Page.ui.tabs.get(tabNumber).sections.get(sectionNumber).setVisible(true); //How to Hide a section using JavaScript? Xrm.Page.ui.tabs.get(tabNumber).sections.get(sectionNumber).setVisible(false); **For CRM 2011 Training, please check out our CRM Training page. Please share |Like in Facebook if you feel like this page is useful.