Again I’m back with Some of the Javascript snippets which we are using around in many scenarios.
To retrieve the value of the CRM field.
Var fieldVal = Xrm.Page.getAttribute("fieldname ").getValue();
To assign value
Xrm.Page.getAttribute("fielname").setValue(“Test”);
To make field readonly /disable /enable
Xrm.Page.getControl("fieldname").setDisabled(true); //Making Readonly/Disable
Xrm.Page.getControl("fieldname").setDisabled(false); //Enable
To update the disable field in CRM
Xrm.Page.getAttribute("fieldname ").setSubmitMode("always");
To Hide/show the field
Xrm.Page.ui.navigation.items.get("fieldname ").setVisible(false); //hide
Xrm.Page.ui.navigation.items.get("fieldname ").setVisible(true); //show
To get the current form type
Xrm.Page.ui.getFormType()
To get the current entity Id
Xrm.Page.data.entity.getId()
Making field mandatory
Xrm.Page.getAttribute(‘fieldname’).setRequiredLevel("required");
Making non-mandatory
Xrm.Page.getAttribute(‘fieldname’).setRequiredLevel("none");
Assigning URL to IFRAME
Var url = http://www.google.com;
Xrm.Page.getControl("IFRAME_fieldname").setSrc(url);
Check my other blog for hiding/Showing sections
No comments:
Post a Comment