locked
Embedding Create form for child entity in IFRAME RRS feed

  • Question

  • Has anyone found any good references to getting this set up? Have found plenty concerning great ways of embedding grids of child entities, advanced finds, etc - but not for a create form.

    We have a custom entity that has a N:1 relationship with a Case, and on a tab within the update form of the Case, want to embed the create form of the child entity so that it is preloaded and don't have to use any form of popup window to create the child record.

    Have toyed so far with this javascript:

    crmForm.all.IFRAME_newform.src = '/' + ORG_UNIQUE_NAME + '/userdefined/edit.aspx?_CreateFromType=' + crmForm.ObjectTypeCode + '&_CreateFromId=' + crmForm.ObjectId + '&etc=10002'
    

    But it's not quite ideal yet. Don't really want the left navigation of the record, or the big title of the form (ok, could probably get rid of those through DHTML of the iframe document model in some way I guess). And also the Save and Close blanks the window afterwards.

    Any other ideas out there?

    Cheers
    Gavin 

    Tuesday, April 20, 2010 8:37 PM

Answers

  • Wednesday, April 21, 2010 8:40 AM
    Answerer
  • Thanks Donna.

    Went with a hybrid of the answer in there and the methods described in the Removing 'Add xxx buttons' that's always linked to. Didn't want to add code to the child entity form, so did it all through the parent:

    var CRM_FORM_TYPE_CREATE = 1;
    var CRM_FORM_TYPE_UPDATE = 2;
    
    
    function HideProgressionNav(Iframe) { 
      if (Iframe != null ) {
        Iframe.onreadystatechange = function EmbedIframe() { 
          if (Iframe.readyState == 'complete') { 
            var iFrame = frames[window.event.srcElement.id]; 
            
    				oNPDoc = iFrame.document;
    				oNB = oNPDoc.getElementById('crmNavBar');
    				if (oNB != null)
    					oNB.style.display = 'none';
    				
    				oMB = oNPDoc.getElementById('crmMenuBar');
    				if (oMB.nextSibling != null)
    					oMB.nextSibling.style.display = 'none';
    				oMB.parentNode.parentNode.setAttribute('height','50');
    				
    				oNPDoc.body.childNodes[0].childNodes[0].childNodes[0].setAttribute('width','1');
    				
    				if (oNPDoc.getElementById('_MBcrmFormSave') != null) {
    					oNPDoc.getElementById('_MBcrmFormSave').style.display = "none";
    				}
    				if (oNPDoc.getElementById('_MBcrmFormSaveAndClose') != null) {
    					oNPDoc.getElementById('_MBcrmFormSaveAndClose').style.display = "none";
    				}
          } 
        } 
      }
    } 
    
    function GetFrameSource(tabSet) {
      if (crmForm.ObjectId != null) {
    
        var oId = crmForm.ObjectId;
        var oType = crmForm.ObjectTypeCode;
        var security = crmFormSubmit.crmFormSubmitSecurity.value;
    
        return "areas.aspx?oId=" + oId + "&oType=" + oType + "&security=" + security + "&tabSet=" + tabSet;
      }
    
      else {
        return "about:blank";
      }
    }
    
    switch (crmForm.FormType)
    {
     case CRM_FORM_TYPE_CREATE:
       break;
     case CRM_FORM_TYPE_UPDATE:
      if (crmForm.all.customerid.DataValue != null) {
    		crmForm.all.IFRAME_newprogression.src = prependOrgName('/userdefined/edit.aspx?_CreateFromType=' + crmForm.ObjectTypeCode + '&_CreateFromId=' + crmForm.ObjectId + '&etc=10002');
    		HideProgressionNav(crmForm.all.IFRAME_newprogression);
    	}
      break;
    }
    
    var actionResolve = document.getElementById('_MIresolve');
    if(actionResolve != null)
      actionResolve.outerHTML='<SPAN></SPAN>'
    
    
    • Marked as answer by Gavin Pollock Friday, April 23, 2010 7:37 AM
    Friday, April 23, 2010 7:37 AM

All replies

  • Wednesday, April 21, 2010 8:40 AM
    Answerer
  • Thanks Donna.

    Went with a hybrid of the answer in there and the methods described in the Removing 'Add xxx buttons' that's always linked to. Didn't want to add code to the child entity form, so did it all through the parent:

    var CRM_FORM_TYPE_CREATE = 1;
    var CRM_FORM_TYPE_UPDATE = 2;
    
    
    function HideProgressionNav(Iframe) { 
      if (Iframe != null ) {
        Iframe.onreadystatechange = function EmbedIframe() { 
          if (Iframe.readyState == 'complete') { 
            var iFrame = frames[window.event.srcElement.id]; 
            
    				oNPDoc = iFrame.document;
    				oNB = oNPDoc.getElementById('crmNavBar');
    				if (oNB != null)
    					oNB.style.display = 'none';
    				
    				oMB = oNPDoc.getElementById('crmMenuBar');
    				if (oMB.nextSibling != null)
    					oMB.nextSibling.style.display = 'none';
    				oMB.parentNode.parentNode.setAttribute('height','50');
    				
    				oNPDoc.body.childNodes[0].childNodes[0].childNodes[0].setAttribute('width','1');
    				
    				if (oNPDoc.getElementById('_MBcrmFormSave') != null) {
    					oNPDoc.getElementById('_MBcrmFormSave').style.display = "none";
    				}
    				if (oNPDoc.getElementById('_MBcrmFormSaveAndClose') != null) {
    					oNPDoc.getElementById('_MBcrmFormSaveAndClose').style.display = "none";
    				}
          } 
        } 
      }
    } 
    
    function GetFrameSource(tabSet) {
      if (crmForm.ObjectId != null) {
    
        var oId = crmForm.ObjectId;
        var oType = crmForm.ObjectTypeCode;
        var security = crmFormSubmit.crmFormSubmitSecurity.value;
    
        return "areas.aspx?oId=" + oId + "&oType=" + oType + "&security=" + security + "&tabSet=" + tabSet;
      }
    
      else {
        return "about:blank";
      }
    }
    
    switch (crmForm.FormType)
    {
     case CRM_FORM_TYPE_CREATE:
       break;
     case CRM_FORM_TYPE_UPDATE:
      if (crmForm.all.customerid.DataValue != null) {
    		crmForm.all.IFRAME_newprogression.src = prependOrgName('/userdefined/edit.aspx?_CreateFromType=' + crmForm.ObjectTypeCode + '&_CreateFromId=' + crmForm.ObjectId + '&etc=10002');
    		HideProgressionNav(crmForm.all.IFRAME_newprogression);
    	}
      break;
    }
    
    var actionResolve = document.getElementById('_MIresolve');
    if(actionResolve != null)
      actionResolve.outerHTML='<SPAN></SPAN>'
    
    
    • Marked as answer by Gavin Pollock Friday, April 23, 2010 7:37 AM
    Friday, April 23, 2010 7:37 AM