10 Useful scripts for Dynamics CRM
1. Get the Guid of logged in userid/username
Xrm.Page.context.getUserId()Xrm.Page.context.getUserName()
2. Get the value from a CRM field:
var fieldvalue= Xrm.Page.getAttribute("fieldSchemaname").getValue() ;
3. Set the value of a CRM field:
Xrm.Page.getAttribute("fieldSchemaname").setValue(value);
4. Hide/Show a tab/section:
Xrm.Page.ui.tabs.get(5).setVisible(false);
Xrm.Page.ui.tabs.get(5).setVisible(true);
5. Call the onchange event of a field:
Xrm.Page.getAttribute("fieldSchemaname").fireOnChange();
6. Get the selected value of picklist:
Xrm.Page.getAttribute("fieldSchemaname").getSelectedOption().text;
7. Set the requirement level:
Xrm.Page.getAttribute("fieldSchemaname").setRequiredLevel(“none”);
Xrm.Page.getAttribute("fieldSchemaname").setRequiredLevel(“required”);
Xrm.Page.getAttribute("fieldSchemaname").setRequiredLevel(“recommended”);
8. Set the focus to a field:
Xrm.Page.getControl(“CRMFieldSchemaName”).setFocus(true);
9. Return array of strings of users security role GUIDs:
Xrm.Page.context.getUserRoles()
10. Get the form type
var formtype=Xrm.Page.ui.getFormType();
No comments:
Post a Comment