Skip to content

Instantly share code, notes, and snippets.

View DynCon365's full-sized avatar

Dynamic Consulting DynCon365

View GitHub Profile
@DynCon365
DynCon365 / gist:c8773cda8d14d5dbf76a2cfa1656c293
Created August 11, 2020 21:36
Dynamics 365/CRM 9.0+ | Pulling data from related entities
//-------------------------------------------------------------------------------------------
// getRelatedInfo
//-------------------------------------------------------------------------------------------
function getRelatedInfo(e) {
// Get the Form Context
var formContext = e.getFormContext();
// Set variables for the related entity to get data from
@DynCon365
DynCon365 / gist:204d031d95090b469465d305828f1c8c
Created August 11, 2020 21:35
Dynamics 365/CRM 9.0+ | Open a specific form based on a field value
//-------------------------------------------------------------------------------------------
// openSpecificForm
//-------------------------------------------------------------------------------------------
function openSpecificForm(e){
// Get the Form Context
var formContext = e.getFormContext();
//if the form is update form
@DynCon365
DynCon365 / gist:0ded6de9791c4a24250f5a3360664b56
Created August 11, 2020 21:32
Dynamics 365/CRM 9.0+ | Use value of an option set to set up a form
//-------------------------------------------------------------------------------------------
// setCustomFormLayout
//-------------------------------------------------------------------------------------------
function setCustomFormLayout(e){
// Consider using Business Rules before using this code
// Get the Form Context
var formContext = e.getFormContext();
@DynCon365
DynCon365 / gist:3f229f50668356f2211184f448c48057
Created August 11, 2020 21:31
Dynamics 365/CRM 9.0+ | Set field requirement level
//-------------------------------------------------------------------------------------------
// setRequiredLevel
//-------------------------------------------------------------------------------------------
function setRequiredLevel(e){
// Consider using Business Rules before using this code
// Get the Form Context
var formContext = e.getFormContext();
@DynCon365
DynCon365 / gist:93944e7e4bba0e962e56babb3f45fcee
Created August 11, 2020 21:30
Dynamics 365/CRM 9.0+ | Show/hide form fields
//-------------------------------------------------------------------------------------------
// showHideFields
//-------------------------------------------------------------------------------------------
// Consider using Business Rules before using this code
function showHideFields(e){
// Get the Form Context
var formContext = e.getFormContext();
@DynCon365
DynCon365 / gist:b80d7b127fe36b7361074fac5360985b
Created August 11, 2020 21:29
Dynamics 365/CRM 9.0+ | Show/hide form sections
//-------------------------------------------------------------------------------------------
// showHideFormSections
//-------------------------------------------------------------------------------------------
// Consider using Business Rules before using this code
function showHideFormSections(e){
// Get the Form Context
var formContext = e.getFormContext();
@DynCon365
DynCon365 / gist:be3d7b036dddb0bdcd36f3a1ef6f39e9
Created August 11, 2020 21:28
Dynamics 365/CRM 9.0+ | Get the value of a date field
//-------------------------------------------------------------------------------------------
// getDateField
//-------------------------------------------------------------------------------------------
function getDateField(e){
// Get the Form Context
var formContext = e.getFormContext();
// Get the value of the Opportunity Est. Close Date
@DynCon365
DynCon365 / gist:ca9d8799a5b8151c5acc3411253899c1
Created August 11, 2020 21:27
Dynamics 365/CRM 9.0+ | Set the value of an option set
//-------------------------------------------------------------------------------------------
// setOptionSetField
//-------------------------------------------------------------------------------------------
function setOptionSetField(e){
// Get the Form Context
var formContext = e.getFormContext();
// Set the value of the Opportunity Status Reason field
@DynCon365
DynCon365 / gist:dd9a9cc21369ccd79c9cacc4554d2864
Created August 11, 2020 21:25
Dynamics 365/CRM 9.0+ | Get the database value and text of an option set
//-------------------------------------------------------------------------------------------
// getOptionSetField
//-------------------------------------------------------------------------------------------
function getOptionSetField(e){
// Get the Form Context
var formContext = e.getFormContext();
// Get the database value of the Opportunity Status Reason field
@DynCon365
DynCon365 / gist:1236985ed52a1d9b605a816417a85d15
Created August 11, 2020 21:24
Dynamics 365/CRM 9.0+ | Set the value of a bit field
//-------------------------------------------------------------------------------------------
// setBitField
//-------------------------------------------------------------------------------------------
function setBitField(e){
// Get the Form Context
var formContext = e.getFormContext();
// Set the value of a custom "Is Decision Maker" checkbox to checked