Tuesday, January 05, 2010

Handling Rollup message with plugins in Microsoft Dynamics CRM 4.0

There are no Rollup message in the list of supported message in SDK. Following trick will help developers to handle this message.

Open Microsoft SQL Server Management Studio, select your organization database in dropdown control, and execute following script:

Update SdkMessageFilter 
Set IsCustomProcessingStepAllowed = 1
Where SdkMessageId in
(Select SdkMessageId From SdkMessage Where Name = 'Rollup')

Now it is possible to register your plugins on rollup message. Open plugin registrator and check it:

First interesting thing I saw when I began to debug plugin is that both PrimaryEntityName and SecondaryEntityName are filled (PrimaryEntityName with entity you search - activitypointer, annotation, incident. e.t.c., SecondaryEntityName with entity from which you want to see related records - contact, account, e.t.c. - all combination can be found in SDK):

Next interesting I've found is content of InputParameters:

"Target" is the array of objects. First object is just string with parent entity record type name. Second object is instance of CrmMoniker class - contains parent entity type name and identifier of record. Third object is instance of QueryExpression class and it contains filters based on which records will be retrieved.
"RollupType" is additional marker what records will be retrieved - property of RollupType enumeration.

Next interesting thing was found OutputParameters property - BusinessEntityCollection - the result of RollupRequest - all entities that meet criterion passed in InputParameters property:

How can this feature be used by developers? In various ways... For example I will answer for myself on answer I was asked here - "Have You figured out how to catch the rollup message to count activities or cases related to an entity?" - now I know how to do it. Other way to use this feature - is to configure rollup filter as you want...

But remember - such customizations are unsupported!

No comments:

Post a Comment