Monday, December 13, 2010

CDC Software Pivotal CRM 6.0: How to pass parameters from one client form to another.

This is a code example that describes how to pass parameters to another form.

Code example: open form B and send custom parameters from form A

//Form A:

TransitionPointParameter transitionParam = new TransitionPointParameter();
//Custom parameters (1 based index)
transitionParam.SetUserDefinedParameter(1, "Hello");
transitionParam.SetUserDefinedParameter(2, 123);

//Auto mapped parameters
transitionParam.AddDefaultColumn("First_Name", "Bobo");

ParameterList parameterList = (ParameterList)transitionParam.Construct();

//Open Form B and pass parameters
Globals.ShowForm("Company", null, parameterList);

//Form B:

//Close caller record
if (this.TransitionPointParameter.UserDefinedParametersNumber > 0)
{
    string message = (string)this.TransitionPointParameter.GetUserDefinedParameter(1);
    int number = (int)this.TransitionPointParameter.GetUserDefinedParameter(2);
}

Thursday, December 2, 2010

MS CRM 4.0: How to hide IFRAME padding in CRM forms

This is the way to remove iframe padding programmatically.
Add setIFrameSource function to your crm form OnLoad event.


function onCrmFormLoaded() {
 // ...

 //Display related records in iframe
 setIFrameSource();
 
 // ...
}

function setIFrameSource() {
 if (crmForm.ObjectId) {
  // Generate url to display related records
  var url = 'areas.aspx?oId=' + crmForm.ObjectId + '&oType=10000&security=852023&tabSet=new_new_myentity=entityA_new_entityB';
  // Set iframe source
  crmForm.all.IFRAME_entity.src = url;
  // Remove padding when iframe is loaded
  crmForm.all.IFRAME_entity.attachEvent('onreadystatechange', onIFrameReady);
 }
 else {
  // Hide iframe
  crmForm.all.IFRAME_entity.parentElement.parentElement.style.display = 'none';
 }
}

function onIFrameReady(e) {
 if (e.srcElement.readyState == 'complete') {
  var doc = e.srcElement.contentWindow.document;
  // Remove scrolling space
  doc.body.scroll = "no";
  // Remove crmGrid default padding
  doc.body.childNodes[0].rows[0].cells[0].style.padding = 0;
 }
}