This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------------------------------------------------------- | |
// getBitField | |
//------------------------------------------------------------------------------------------- | |
function getBitField(e) { | |
// Get the value of a custom "Is Decision Maker" checkbox on a Contact | |
var decisionMaker = formContext.getAttribute("new_isDecisionMaker").getValue(); | |
// checked will return 1; unchecked will return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------------------------------------------------------- | |
// setNumericField | |
//------------------------------------------------------------------------------------------- | |
function setNumericField(e){ | |
// Get the Form Context | |
var formContext = e.getFormContext(); | |
// Set the Contact's age to 25 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------------------------------------------------------- | |
// getNumericField | |
//------------------------------------------------------------------------------------------- | |
function getNumericField(e){ | |
// Get the Form Context | |
var formContext = e.getFormContext(); | |
// Get the value of a custom Age field on a Contact |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------------------------------------------------------- | |
// setLookupField | |
//------------------------------------------------------------------------------------------- | |
function setLookupField(e){ | |
// Get the Form Context | |
var formContext = e.getFormContext(); | |
// First, you need the GUID, Name and Entity Type stored as variables |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------------------------------------------------------- | |
// getLookupFieldText | |
//------------------------------------------------------------------------------------------- | |
function getLookupFieldText(e){ | |
// Get the Form Context | |
var formContext = e.getFormContext(); | |
// Get the Parent Company name of a Contact |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------------------------------------------------------- | |
// setTextField | |
//------------------------------------------------------------------------------------------- | |
function setTextField(e){ | |
// Get the Form Context | |
var formContext = e.getFormContext(); | |
// Set the Contact's first name to Joe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------------------------------------------------------- | |
// getTextField | |
//------------------------------------------------------------------------------------------- | |
function getTextField(e){ | |
// Get the Form Context | |
var formContext = e.getFormContext(); | |
// Get the value of a Contact's first name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Consider using Business Rules before using this code | |
// Show a form field | |
Xrm.Page.ui.controls.get("new_formField").setVisible(true); | |
// Hide a form field | |
Xrm.Page.ui.controls.get("new_formField").setVisible(false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the value of the Opportunity Status Reason field | |
var statusReason = Xrm.Page.data.entity.attributes.get("statuscode").getValue(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the text of the Opportunity Status Reason field | |
var statusReason = Xrm.Page.data.entity.attributes.get("statuscode").getText(); |