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 comment