Automatically share a personal view with another user
Recently we needed to share personal views with a system/service user to draw Bing maps. (keep an eye out for a cool blog post about geo mapping and geo boundary integration with advanced find views).
Advanced Find views are stored under the userquery entity; unfortunately this entity is marked as private by CRM, meaning we’re not able to register plugins, there is an unsupported work around though.
If you open up the SdkMessageFilter table and set IsCustomProcessingStepAllowed to 1 on the userquery entity you’ll be able to register plugins under the userquery entity.
Next step is to create the plugin and write some code to share this advanced find view with another user, to do this programmatically use the code below.
{
PrincipalAccess = new PrincipalAccess
{
AccessMask = AccessRights.ReadAccess,
Principal = new SecurityPrincipal
{
PrincipalId = userId,
Type = SecurityPrincipalType.User
}
},
Target = new TargetOwnedDynamic
{
EntityId = queryId, EntityName = "userquery"
}
};
To get the queryId use the Input/OutputParameters of the IPluginExecutionContext, to view other parameters that are passed in via the IPluginExecutionContext use our mSpy tool (http://mspy.codeplex.com), it takes the guess work out of writing plugins!