http://www.powerobjects.com/blog/2011/01/14/crm-2011-useful-javascript-tidbits/
Xrm.Page.ui.tabs.get(5).SetVisible(true);
Xrm.Page.getAttribute(“CRMFieldSchemaName”).setRequiredLevel(“required”);
Xrm.Page.getAttribute(“CRMFieldSchemaName”).setRequiredLevel(“recommended”);
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(5).SetVisible(false);Xrm.Page.ui.tabs.get(5).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()Hide/Show Tabs and Sections
function setVisibleTabSection(tabname, sectionname, show)
{
var tab = Xrm.Page.ui.tabs.get(tabname);
if (tab != null)
{
if (sectionname == null)
tab.setVisible(show);
else {
var section = tab.sections.get(sectionname);
if (section != null)
{
section.setVisible(show);
if (show)
tab.setVisible(show);
}
}
}
}
Comments
object expected
the code is Xrm.Page.data.entity.getEntityName()
Vee Eee Technologies
i have a problem. i have set a field value default during on load . but i want to change the value dynamic during ON SAVE event, can u send me java script code for it.
this is my java script
Xrm.Page.getAttribute(“po_CRMFieldSchemaName”).setValue(‘My New Value’);