Here’s a quick reference guide covering Microsoft Dynamics CRM syntax for common java script.
Most of the examples are provided as functions that you can easily test in the On Load and On Save by generating form Context from execution Context.
Show or Hide Navigation Items
function ShowHideNavigationItems(executionContext) {
try {
//Get the form context
var formContext = executionContext.getFormContext();
//Show Organizations
formContext.ui.navigation.items.get(“organizations”).setVisible(true);
//Hide Organizations
formContext.ui.navigation.items.get(“organizations”).setVisible(false);
}
catch (e) {
Xrm.Utility.alertDialog(e.message);
}
}
Set Form Notification
function SetFormNotification(executionContext) {
try {
//Get the form context
var formContext = executionContext.getFormContext();
//Set Form Notification
formContext.ui.setFormNotification(“This is a MS DYNAMICS CRM Form Notification”, “INFO”, “1”);
}
catch (e) {
Xrm.Utility.alertDialog(e.message);
}
}
Clear Form Notification
function ClearFormNotification(executionContext) {
try {
//Get the form context
var formContext = executionContext.getFormContext();
//Clear Form Notification
formContext.ui.clearFormNotification(“This is a MS DYNAMICS CRM Form Notification”, “INFO”, “1”);
}
catch (e) {
Xrm.Utility.alertDialog(e.message);
}
}
Show Progress Indicator
function ShowProgressIndicator() {
try {
Xrm.Utility.showProgressIndicator(“The Page is Loading… Please wait…”);
}
catch (e) {
Xrm.Utility.alertDialog(e.message);
}
}
Clear Progress Indicator
function ClearProgressIndicator() {
try {
Xrm.Utility.closeProgressIndicator();
}
catch (e) {
Xrm.Utility.alertDialog(e.message);
}
}
Show Hide Tabs based on field values
function ShowHideTabs(executionContext) {
try {
//Get the form context
var formContext = executionContext.getFormContext();
var isProcessed = formContext.getAttribute(“progres_isprocessed”).getValue(); //Two Option set field
var generalTab = formContext.ui.tabs.get(“GENERAL”); //Get Tab
if (isProcessed === false) {
generalTab.setVisible(false); //Hide Tab
} else {
generalTab.setVisible(true); //Show Tab
}
formContext.ui.tabs.get(“CASH_PLAN_FLOW_DETAILS”).setDisplayState(“collapsed”); //Collapse Tab
}
catch (e) {
Xrm.Utility.alertDialog(e.message);
}
}
Show Hide Sections based on field values
function ShowHideSections(executionContext) {
try {
//Get the form context
var formContext = executionContext.getFormContext();
var isProcessed = formContext.getAttribute(“progres_isprocessed”).getValue(); //Two Option set field
var generalTab = formContext.ui.tabs.get(“GENERAL”); //Get Tab
var asstPackages = generalTab.sections.get(“ASSISTANCE_PACKAGES”); //Get sections
var payments = generalTab.sections.get(“PAYMENT_RECORDS”); //Get sections
if (isProcessed === false) {
asstPackages.setVisible(true); //Show Section
payments.setVisible(false); //Hide Section
} else {
asstPackages.setVisible(false); //Show Section
payments.setVisible(true); //Show Section
}
formContext.ui.tabs.get(“CASH_PLAN_FLOW_DETAILS”).setDisplayState(“collapsed”); //Collapse Tab
}
catch (e) {
Xrm.Utility.alertDialog(e.message);
}
}