الثلاثاء، 14 مايو 2013

CRM 2011: Javascript Xrm.Page Basics

//***** Get the value from a CRM field

 var varMyValue = Xrm.Page.getAttribute(“CRMFieldSchemaName”).getValue() ;

//****** Set the value of a CRM field

 Xrm.Page.getAttribute(“po_CRMFieldSchemaName”).setValue(‘My New Value’);

//***** Hide/Show a tab/section

 Xrm.Page.ui.tabs.get("Tab Name").setVisible(false);

 Xrm.Page.ui.tabs.get("Tab Name").sections.get("Section Name").setVisible(true);

//*****Call the onchange event of a field

 Xrm.Page.getAttribute(“CRMFieldSchemaName”).fireOnChange();

//****Get the selected value of picklist

 Xrm.Page.getAttribute(“CRMFieldSchemaName”).getSelectedOption().text;

//******Set the requirement level

 Xrm.Page.getAttribute(“CRMFieldSchemaName”).setRequiredLevel(“none”);
 Xrm.Page.getAttribute(“CRMFieldSchemaName”).setRequiredLevel(“required”);
 Xrm.Page.getAttribute(“CRMFieldSchemaName”).setRequiredLevel(“recommended”);

//********Set the focus to a field

 Xrm.Page.getControl(“CRMFieldSchemaName”).setFocus(true);

//***********Stop an on save event
 event.returnValue = false;

//**** Return array of strings of users security role GUIDs:

 Xrm.Page.context.getUserRoles()


Method returns a Boolean value that indicates if any fields in the form have been modified.

Xrm.Page.data.entity.getIsDirty() 

ليست هناك تعليقات:

إرسال تعليق