Audience: Customers/Partners who want to customize the CRM Connector for GP to support update/delete of new entities (entities which are not supported out-of-box). It is expected that  the user performing these steps is aware of the map creation process in BizTalk Server 2004.

 

Scenario: You wants to integrate new entities (example: CRM Lead and GP Prospect) and support create/update/delete operations asynchronously.


A “Create” map is comparatively easier but for a "Update" or "Delete" map the primary key of the destination system will be required.
The primary key in the destination application is required to determine which entity instance needs to be updated or deteled. (For example: to update the CRM Lead on update of a GP Prospect, the CRM leadid (primary key of CRM Lead) will be required to identify which CRM Lead needs to be updated)


This piece of information can be easily queried from the CRM Connector for GP database, if you know how links are managed by the CRM Connector for GP.
 

Example: Consider you need to create an "Update" map between CRM Lead and GP Prospect. PROSPID in GP and leadid in CRM are the primary keys for these entities. When an update on a GP Prospect occurs an xml for that prospect reaches the CRM Connector for GP which has the PROSPID populated in it. In the update map, you need to keep an advanced functoid between PROSPID and leadid. This functoid will query the CRM Connector for GP database to determine which leadid is linked with the PROSPID. I suggest you create your own dll which has a public method which can query the link. Then in the advanced script functoid you link this dll and the method.

 

Link management in CRM Connector for GP database

Intentityinstance(Table in integration database): Primary key is instanceid. Each row will correspond to one entity instance of  an application. “appentitykey” will contain the information about the primary key of that entity instance. So all the integrated entity instances of either CRM or GP will have entries in this table.

 

Intentityinstancelink(Table in integration database): Instanceid1 and instanceid2 of this table are corresponding to instanceid of Intentityinstance table. Linkid is the primary key. So this table is actually just linking two instances of Intentityinstance table.

 

So in our example, to find out leadid in CRM, first query Intentityinstance table where appentitykey contains PROSPID and the value of PROSPID. So you have the instanceid of the prospect instance.

Now query intentityinstancelink table where either instanceid1 equals to “the instanceid of propect instance” or instanceid2 equals to “the instanceid of propect instance”. If the link exists you will find one link in this table. If instanceid1 matches then you take instanceid2 or vice-versa. So you have “instanceid of lead instance”.

Now query intentityinstance table again to query the lead instance. Appentitykey will contain the leadid guid. Parse and extract the value and copy this to the leadid node of crm schema in the map.

 

I am attaching a code snippet(in C#.Net) which will give the feel of how you can query the integration database. This code can’t be used directly(as variables and references are not specified), I suggest you understand the logic and modify the code to suit your purpose.