Get a value from CRM field
var value= Xrm.Page.getAttribute(“fieldschemaname”).getValue();Set Value to field
Xrm.Page.getAttribute(“fieldschemaname”).setValue();
Get Entity ID
var ID= Xrm.Page.data.entity.getId();
Hide a Tab/Section from CRM form
Tab
Xrm.Page.ui.tabs.get(tabname/SectionName).setVisible(false);
Section inside a Tab
Xrm.Page.ui.tabs.get("tab_3").sections.get("tab_3_section_2").setVisible(false);
Xrm.Page.ui.tabs.get("tab_3").sections.get("tab_3_section_2").setVisible(false);
Show a Tab/Section from CRM form
TabXrm.Page.ui.tabs.get(tabname/SectionName).SetVisible(true);
Section inside a Tab Xrm.Page.ui.tabs.get("tab_3").sections.get("tab_3_section_2").setVisible(true);
Set Focus
Xrm.Page.getControl("fieldschemaname").setFocus(true);
Expand / Collapse Tab
Expand tab
Xrm.Page.ui.tabs.get("tabname").setDisplayState("expanded");
Collapse tab
Xrm.Page.ui.tabs.get("tabname").setDisplayState("collapsed");
Set Requirements field
Xrm.Page.getAttribute(“fieldschemaname”).setRequiredLevel("none");
Xrm.Page.getAttribute(“fieldschemaname”).setRequiredLevel("required");
Xrm.Page.getAttribute(“fieldschemaname”).setRequiredLevel("recommended");
Xrm.Page.getAttribute(“fieldschemaname”).setRequiredLevel("required");
Xrm.Page.getAttribute(“fieldschemaname”).setRequiredLevel("recommended");
Set Focus field
Xrm.Page.getControl(“fieldschemaname”).setFocus(true);
Get Security role
Xrm.Page.context.getUserRoles();
Get Lookup ID and name
var lookupvalue = new Array();
lookupvalue = Xrm.Page.getAttribute("fieldschemaname").getValue();
if (lookupvalue !=null)
{
var name = lookupvalue [0].name;
var id = lookupvalue [0].id;
}
Refresh Ribbon Button
Xrm.Page.ui.refreshRibbon()
Set a lookup value
var lookup = new Array();
lookup[0] = new Object();
lookup[0].id =valueid;
lookup[0].name = valuename;
lookup[0].entityType = entityname;
Xrm.Page.getAttribute ("fieldschemaname").setValue(lookup);
Set error message
Xrm.Page.getControl("fieldschemaname").setNotification("message");
Get Current User
var userID = Xrm.Page.context.getUserId();
var userName = Xrm.Page.context.getUserName();
Save and Close
Save function
Xrm.Page.data.entity.save();
Save and Close function
Xrm.Page.data.entity.save("saveandclose");
Save and New function
Xrm.Page.data.entity.save("saveandnew");
Close function
Xrm.Page.ui.close();
No comments:
Post a Comment