Get the value from a CRM field
1 | var varMyValue = Xrm.Page.getAttribute(“CRMFieldSchemaName”).getValue() ; |
Set the value of a CRM field
1 | Xrm.Page.getAttribute(“po_CRMFieldSchemaName”).setValue(‘My New Value’); |
Hide/Show a tab
1 | Xrm.Page.ui.tabs.get(5).setVisible( false ); |
2 | Xrm.Page.ui.tabs.get(5).setVisible( true ); |
Hide/Show a section
1 | Xrm.Page.ui.tabs.get(5).sections.get(0).setVisible( false ); |
2 | Xrm.Page.ui.tabs.get(5).sections.get(0).setVisible( true ); |
Call the onchange event of a field
1 | Xrm.Page.getAttribute(“CRMFieldSchemaName”).fireOnChange(); |
Get the selected value of picklist
1 | Xrm.Page.getAttribute(“CRMFieldSchemaName”).getSelectedOption().text; |
Set the requirement level
1 | Xrm.Page.getAttribute(“CRMFieldSchemaName”).setRequiredLevel(“none”); |
2 | Xrm.Page.getAttribute(“CRMFieldSchemaName”).setRequiredLevel(“required”); |
3 | Xrm.Page.getAttribute(“CRMFieldSchemaName”).setRequiredLevel(“recommended”); |
Set the focus to a field
1 | Xrm.Page.getControl(“CRMFieldSchemaName”).setFocus( true ); |
Stop an on save event
1 | event.returnValue = false ; |
Return array of strings of users security role GUIDs:
1 | Xrm.Page.context.getUserRoles() |
Get record GUID
1 | var recordId = Xrm.Page.data.entity.getId()l |
2 | var recordIdWithoutCurlyBraces = Xrm.Page.data.entity.getId().substring(1,37); |
Get event source
1 | var eventSource = executionContext.getEventSource(); // tick Pass execution context as first parameter |
Get event source (fieldname)
1 | var fieldName = executionContext.getEventSource().getName(); // tick Pass execution context as first parameter |
Get event source (value)
1 | var fieldValue= executionContext.getEventSource().getValue(); // tick Pass execution context as first parameter |
Set Lookup Value
1 | Xrm.Page.getAttribute( 'new_fieldid' ).setValue([{ id: 'guid' , name: fullName, entityType: 'entityTypeName' }]); |
Disable/Enable field
1 | Xrm.Page.getControl(fieldName).setDisabled( true ); |
2 | Xrm.Page.getControl(fieldName).setDisabled( false ); |
field
1 | Xrm.Page.ui.controls.get(fieldName).setVisible( false ); |
2 | Xrm.Page.ui.controls.get(fieldName).setVisible( true ); |
Get CRM Form Type
01 | var FORM_TYPE_CREATE = 1; |
02 | var FORM_TYPE_UPDATE = 2; |
03 | var FORM_TYPE_READ_ONLY = 3; |
04 | var FORM_TYPE_DISABLED = 4; |
05 | var FORM_TYPE_QUICK_CREATE = 5; |
06 | var FORM_TYPE_BULK_EDIT = 6; |
07 | |
08 | var formType = Xrm.Page.ui.getFormType(); |
09 | if (formType == FORM_TYPE_CREATE) { |
10 | } |
11 | else { |
12 | } |
No comments:
Post a Comment