The requirement is:
When a user clicks on a form's tab in a Crm detail form, a record needs to be entered into an (Oracle) database. In case of success show a webpage from a particular url (to an application that reacts to the data in the record), in case of failure show a message.
The most elegant way to react to the onclick event of the Tab, in my opinion is to attach to this event in Javascript, ofcourse it is important not to interfere with the attached handler that is already present and takes care of the showing/hiding of the tab's content.

First I took the IE Developer Toolbar, and with the 'Find' > 'Select Element by Click' functionality, I reduced the Tab's id: 'tab4Tab'.
In the Onload handler, of the Form.Properties I added this:

   1:  var tabVar= crmForm.all.tab4Tab; 
   2:  if(typeof(tabVar) != "undefined" && tabVar != null) 
   3:  { 
   4:       crmForm.all.tab4Tab.attachEvent('onclick',insertRecordAndRedirect, false)
   5:  } 
Listing 1

First the tab object with id: 'tab4Tab' is put into a variable called 'tabVar'.
When this variable is not null and not 'undefined', the function called: 'insertRecordAndRedirect' is attached to the onclick of the 'crmForm.all.tab4Tab' object.

So the function 'insertRecordAndRedirect' is called, the moment the Tab with id: 'tab4Tab' is clicked.
This function is also inserted in the Onload handler, of the Form.Properties (like listing 1):

   1:  function insertRecordAndRedirect()
   2:  {
   3:      var id = crmForm.objectId.value;
   4:      document.all.IFRAME_CrmTab.src ='http://www.henrycordes.nl/?tag=/'+id;
   5:  }
Listing 2

The function reads the value (a Guid) from the objectId property of the crmForm object (the UniqueIdentifier of the database record, from which the details are shown in the form). The aspx page that is called takes care of the inserting of the record into the database, using the provided querystring parameter.

In my case, this works really good, and it also solved an issue I had with GoogleMaps and LiveMaps. Because the tabs on which I put the maps are invisible when the form loads, the maps do not seem to know how big they are.

The result is:

  • In the case of GoogleMaps that the center of the map (the chosen spot on the map is centered) always was on (0,0). Left=0, top=0. When using the 'onclick of the Tab' approach, the map is loaded when the tab is clicked, so the map is visible and the map is centered as intended.
  • In the case of LiveMaps, only the right, lower corner of the map was visible in the left, upper corner of the iframe. But when using the 'onclick of the Tab' approach, the map is loaded when the tab is clicked and the map is completely visible and centered as intended.

Henry Cordes
My thoughts exactly...


CRM 4.0 Workflows don't start

Published 4/1/2008 by Henry in CRM
Tags:

In CRM 4.0 the MS CRM Workflow Service is not available anymore. CRM 4.0 has one Async Service the 'Microsoft CRM Asynchronous Processing Service'. The Microsoft CRM Asynchronous Processing Service takes care of all asynchronous processess that run within CRM like Workflow and Plugins (former Callouts). 

The Microsoft Dynamics CRM system architecture can be divided into 3 major components: the core system, which features the event execution pipeline, the database component, which hosts the asynchronous queue, and the asynchronous service. One benefit of the scalable architecture of Microsoft Dynamics CRM is that the asynchronous service can be hosted on servers other than the Microsoft Dynamics CRM server. This distributed processing capability can result in improved performance of Microsoft Dynamics CRM.

At a client I work on a CRM 4.0 system, my help was asked when updated workflows (from CRM 3.0 to CRM 4.0) that worked in CRM 3.0 did not work.
I soon came to the conclusion that the workflows did not even started. First I tried changing the executing identity on the service, which did not change anything.

After googling I found that lots of people had this problem and that the problem always was related to the MS CRM Website running with a hostheader, or second ip-address.
After trying out several different options my conclusion is that: 

CRM 4.0 needs to run without a hostheader and with the IP-address option 'All unassigned' chosen.
So you cannot use another IP-address and you cannot use hostheaders (if you want the workflow to function)!

I already found out that the CrmDiscoveryService Web service under the hood uses the machinename to connect to the CRMService and the MetadataService, when I tried to register a Plugin using the PluginRegistration Tool.
Which in itself is remarkable IMHO, the reason for a DiscoveryService is, I think, to decouple these services, which is rather hard if you can only connect using the machinename.

Anyway, if you got this issue make sure you use the following settings (the TCP port is not important in this case, you can use 5555 or 80 or another port):

IIS Website settings for MS CRM 4.0 website, assing no ipaddress and do not use hostheader
All unassigned without hostheader

Henry Cordes
My thoughts exactly...