//FIELDS - Values // Get Text Value Xrm.Page.getAttribute("feildName").getText(); //Get Picklist Value Xrm.Page.getAttribute("FieldName").getValue(); // Set Value Xrm.Page.getAttribute("FieldName").setValue(newValue); //GENERAL // Get Form Type Xrm.Page.ui.getFormType(); //Get Record Id Xrm.Page.data.entity.getId(); //Prevent Saving ExecutionObj.getEventArgs().preventDefault(); //Get user Id Xrm.Page.context.getUserId(); // Force Submit Xrm.Page.getAttribute("FieldName").setSubmitMode("always"); //Set Required Level Xrm.Page.getAttribute("FieldName").setRequiredLevel("none"); Xrm.Page.getAttribute("FieldName").setRequiredLevel("required"); Xrm.Page.getAttribute("FieldName").setRequiredLevel("recommended"); //Get Server Url var context = Xrm.Page.context; var serverUrl = context.getServerUrl(); //IFRMAE //Set IFrams url Xrm.Page.getControl("IFRAME_Name").setSrc(URL_IFRAME_CALLSCRIPT); //SHOW/HIDE/DISABLE // Disable Field Xrm.Page.getControl("FieldName").setDisabled(true); //Hide Field Xrm.Page.ui.controls.get("FieldName").setVisible(false); //Hite Section Xrm.Page.ui.tabs.get("TabNumber").sections.get('SectionName').setVisible(flag); //Hide Tab Xrm.Page.ui.tabs.get("TabNumber").setVisible(false); //Tab Expand Xrm.Page.ui.tabs.get(1).setDisplayState("expanded"); Xrm.Page.ui.tabs.get(1).setDisplayState("collapsed"); //PICKLIST // Get Selecte Text from picklist Xrm.Page.getAttribute("FieldName").getSelectedOption().text; //Remove Option from Picklist Xrm.Page.getControl("FieldName").removeOption(3); //Add Option to Picklist function AddOption(value, text, index) { var option = new Option(); option.text = text; option.value = value; typeControl.addOption(option, index); } //LOOKUP //Populate Lookup function PopulateTemplateLookup(recordid, recordName) { Xrm.Page.getAttribute("lookupId").setValue([{ id: recordid, name: recordName, entityType: "EntityName"}]); } //Get/Check Lookup Values var lookupObject = Xrm.Page.getAttribute("lookupfield"); if (lookupObject != null) { var lookUpObjectValue = lookupObject.getValue(); if ((lookUpObjectValue != null)) { var lookuptextvalue = lookUpObjectValue[0].name; var plookupid = lookUpObjectValue[0].id; } } //Disable Form Fields function doesControlHaveAttribute(control) { var controlType = control.getControlType(); return controlType != "iframe" && controlType != "webresource" && controlType != "subgrid"; } function disableFormFields(onOff) { Xrm.Page.ui.controls.forEach(function (control, index) { if (doesControlHaveAttribute(control)) { control.setDisabled(onOff); } }); } //Set Email To [Party List] function setToPartyList() { var partlistData = new Array(); partlistData[0] = new Object(); partlistData[0].id = '{08C6AFB3-9673-E011-8720-00155DA5304E}'; // userId partlistData[0].name = 'Jill Frank'; //user name partlistData[0].entityType = 'systemuser'; // Entity name Xrm.Page.getAttribute("to").setValue(partlistData); }MSDN Reference :http://msdn.microsoft.com/en-us/library/jj602964.aspx
Tuesday, July 30, 2013
CRM 2011 - Javascript samples
Subscribe to:
Post Comments (Atom)
MS CRM 2011 KB Article customization Issue.
Recently I have encountered some issue while customizing Kb Article Entity. I was doing following configuration in Article form. 1. Add Ba...
-
Recently I wanted to find out users who are not in the correct time zone in CRM System. To change the time zone or user related settings we ...
-
If you want to take part in the internet as a business, information resource, directory, or as a hobbyist wanting to share data, informatio...
-
Do you need to recover lost files, photos or documents? You're sure that a file was on your hard disk some time ago, but now it seems to...
Xrm.Page.getControl("IFRAME_Name").setSrc(URL_IFRAME_CALLSCRIPT);
ReplyDeleteis not working in CRM 2013.