Archive

Posts Tagged ‘personal view’

CRM 2011 Restrict Duplicate Personal View

November 22, 2011 Leave a comment

Recently we got a request from one of our user to restrict the personal view with same name. Having my previous blog in mind, thought that we can do something with User Query entity but when I am trying to register a plugin on User Query entity User Query is not listed.

I am stuck. Then I took the help of CRM Development Forum to solve this, thanks to Mahender and Gayan Perera.

As mentioned by Gayan, I updated the SdkMessageFilter & SdkMessageFilterasifPublished tables and set IsCustomProcessingStepAllowed to 1 on the userquery entity. Then I was able to see the userquery entity in the plugin registration list.

Used the below code to restrict the duplicates in the personal views

EntityCollection listrecords = new EntityCollection();
FilterExpression filterExp = new FilterExpression();
filterExp = new FilterExpression()
{
Conditions =
{
new ConditionExpression ("name", ConditionOperator.Equal, name)
}
};
QueryExpression query = new QueryExpression()
{
EntityName = "userquery",
ColumnSet = new ColumnSet(new string[] { "name" }),
Criteria = filterExp
};

listrecords = service.RetrieveMultiple(query);

if (listrecords.Entities.Count > 0)
throw new InvalidPluginExecutionException("Personel View with this name already exists.");

This has given us a way to solve this in an unsupported way. My manager agreed to go with unsupported way so I did. Hope this will help somebody…

Advertisements

Personal View Sharing & Cloning

October 31, 2011 2 comments

We all know that there is no provision to see the personal views of other users unless until those are shared. Even System Administrator of the system cannot access personal views of other users.

We had some requirements in our recent projects to Clone or Share personal views. Here is the way

1. Personal views created by users are not storing into SavedView entity, which normally used to store system level views

2. There is another entity “UserQuery” to which these personal views are getting stored. There are tables and views available in database.

3. But UserQuery is nowhere available in the CRM UI to update the access level or the customizations, this has been used in background

4. When I generate the entity model class using CRMSVCUTIl.EXE it has generated a class with name UserQuery

5. That’s it, using service calls we can Create, Update and Share the records. Only problem is we need to use Impersonate user to retrieve or create the records for that user