Search code examples
c#pluginsdynamics-crmmicrosoft-dynamics

Dynamics CRM - C# Plug-in for specific view


I've written a plugin in C# that runs when a specific view "My activities" for example is called. How can I specify my plugin ONLY to run when this view is called and not when "Closed activities", "All activities", etc. are?

And will the plugin I'm writing still work when Dynamics will be updated or in 1 year or 2?


Solution

  • Within a plugin it is not possible to determine which view the user exactly selected. You can however get access to the query the view is based upon.

    Register your plugin for the synchronous post RetrieveMultiple message of the appropriate entity. The Inputparameters collection of the IPluginExecutionContext object will contain a property named "Query" holding the Original QueryExpression. You can examine this query (e.g. the columns that are selected) and tweak the entities returned by the query in the Outputparameters collection.

    Years ago I successfully used this approach to provide realtime translations of data on a multi-language system.