JavaScript executed from Ribbon on GridView

I had to fix the following.
Disable the Activate button on subentity records based on some value of the parent record.

The disabling should be done on the Edit-form… but in the subgrid as well.
The absense of the webresources on the subgrid was the challenge.
Here’s how:

function EnableActivateButton() {
   if (quoteid === "" && contractid === "") { return false; } 

   try {
      var varMyValue = Xrm.Page.getAttribute("CRMFieldSchemaName").getValue(); 
   }
   catch (e) {
      var entity = document.parentWindow.parent.Xrm.Page.data.entity.getEntityName(); 
      var recordid = document.parentWindow.parent.Xrm.Page.data.entity.getId(); 
      if (recordid === "") { return false; }
   }
}

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 )

Google photo

You are commenting using your Google 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