// 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…
BLOG
How to Get the changed data from form using Jscript?
/ JavaScript/JScript in CRM 2011 | CRM 2011 Training Series //How to Get the changed data using Jscript? var ChangedData = Xrm.Page.data.entity.getDataXml(); **For CRM 2011 Training, please check out our CRM Training page. Please share |Like in Facebook if you feel like this page is useful.
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 trigger On Save function using JavaScript?
// JavaScript/JScript in CRM 2011 | CRM 2011 Training Series //How to trigger On Save function using JavaScript? Xrm.Page.data.entity.save(); **For CRM 2011 Training, please check out our CRM Training page. Please share |Like in Facebook if you feel like this page is useful.
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 hide a tab using JavaScript?
//How to hide a tab using JavaScript? //Hide/Show a tab Xrm.Page.ui.tabs.get(5).setVisible(false); Xrm.Page.ui.tabs.get(5).setVisible(true); **For CRM 2011 Training, please check out our CRM Training page. Please share |Like in Facebook if you feel like this page is useful.
How to Call the onchange event of a field?
//How to Call the onchange event of a field Xrm.Page.getAttribute(“CRMFieldSchemaName”).fireOnChange(); Please share |Like in Facebook if you feel like this page is useful.
How to Get the selected value of picklist using JavaScript?
//How to Get the selected value of picklist Xrm.Page.getAttribute(“CRMFieldSchemaName”).getSelectedOption().text; **For CRM 2011 Training, please check out our CRM Training page. Please share |Like in Facebook if you feel like this page is useful.
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 the focus to a field using JavaScript?
//How to set the focus to a field using JavaScript? Xrm.Page.getControl(“CRMFieldSchemaName”).setFocus(true); **For CRM 2011 Training, please check out our CRM Training page. Please share |Like in Facebook if you feel like this page is useful.
How to Stop an on save event using JavaScript?
//How to Stop an on save event using JavaScript? event.returnValue = 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.
How to return array of strings of users’ security role GUIDs using JavaScript?
//How to return array of strings of users’ security role GUIDs using JavaScript? Xrm.Page.context.getUserRoles(); **For CRM 2011 Training, please check out our CRM Training page. Please share |Like in Facebook if you feel like this page is useful.
How to trigger Close function using JavaScript?
// How to trigger Close function using JavaScript? Xrm.Page.ui.close(); **For CRM 2011 Training, please check out our CRM Training page. Please share |Like in Facebook if you feel like this page is useful.
How to Get current record id using JavaScript?
// How to Get current record id using JavaScript? var Id = Xrm.Page.data.entity.getId(); **For CRM 2011 Training, please check out our CRM Training page. Please share |Like in Facebook if you feel like this page is useful.
How to Get server URL using JavaScript?
// How to Get server URL using JavaScript? var serverURL = Xrm.Page.context.getServerUrl(); **For CRM 2011 Training, please check out our CRM Training page. Please share |Like in Facebook if you feel like this page is useful.
How to check if a form is modified using JavaScript?
// How to Get modified form using JavaScript? //How to check if a form is modified using JavaScript? var ismodified = Xrm.Page.data.entity.getIsDirty(); **For CRM 2011 Training, please check out our CRM Training page. Please share |Like in Facebook if you feel like this page is useful.
How to Get current entity name using JavaScript?
// How to Get current entity name using JavaScript? var entity = Xrm.Page.data.entity.getEntityName(); **For CRM 2011 Training, please check out our CRM Training page. Please share |Like in Facebook if you feel like this page is useful.
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.
CRM 2011 JavaScript Objects – Layout and Controls Hierarch
This figure gives you an idea of how the JavaScript components are available in the hierarchy. **For CRM 2011 Training, please check out our CRM Training page. Please share |Like in Facebook if you feel like this page is useful.
