D365 Error · Dynamics CRM Javascript · Javascript

Dynamics CRM Javascript Error Cannot read property ‘getFormContext’ of undefined

If you are getting “Cannot read property ‘getFormContext’ of undefined” error, please make sure that you check “Pass execution context as first parameter” checkbox in the event handler properties.

Random Javascript code to Hide Quote sungrid on Oppotunity based on Two option field

Requirement Forum link – https://community.dynamics.com/365/sales/f/dynamics-365-for-sales-forum/394826/locking-ability-to-create-quote-until-required-approvals-met/1065876#1065876

function HideQuoteTab(executionContext) {
var _formContext=executionContext.getFormContext();
if(_formContext.getAttribute(“new_approved”).getValue() == false) {
alert(“Value is NO”)
else if(_formContext.getAttribute(“new_approved”).getValue() == true){
alert(“Value is yes”);

Attach above function on onload and onchange event on the opportunity form.

Hope this helps!


2 thoughts on “Dynamics CRM Javascript Error Cannot read property ‘getFormContext’ of undefined

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s