There are often times when a customer will want to know what records a Contact is viewing in the CRM Dynamics Portal. Historically, this capability was available out of the box with the Tracking feature included in the Portal solution but due to performance issues, the Web Page Tracking feature was deprecated and is no longer an option. However, with a little creativity and some custom coding, that particular information can be captured and stored within Dynamics CRM.
It may sound complicated but it’s not. I will break it down into some simple steps.
First there needs to be a custom Entity in CRM, this is the entity that our Fetch XML will query against and will trigger our Plug-in
I have created an entity called Custom Portal Action and it contains two string attributes, Action and Parameters (I will explain how these attributes are used later)
Also created another entity called Portal Incident Tracking with two lookup attributes, one for Contact and one for the Incident since I’m going to be tracking Portal User’s accessing Case records via the Portal. Of course this entity could be setup to track other entities or even some other information regarding the Portal page that is be viewed. For this example I’m just going to track the Contact and the Case record that was viewed.
Secondly there needs to be a new Web Template that will contain the Liquid code to query the Custom Portal Action. I’ll include all the code samples at the end of this article for simple cut and pasting.
Now create the Page Template that will use this Web Template
And then create a Web Page that will use this Page Template
Now for the final part, a plug-in will be needed to capture the Fetch Query and create our tracked record. Using the C# code below in the Plug-In Class will capture the FetchXML Query and extract the Parameter value, in this instance it’s the User Id and Case Id delimited with commas. The code will parse the string and break it into a string array, then assign those values to the new Portal Incident Tracking record.
Once you have the Plug-In created and deployed to your CRM instance you simply need to connect it to the correct message for the Custom Portal Action entity. It will need to be setup for the RetrieveMultiple Message
Here is the Web Template Liquid code