I'm using the code from the below blog entry to re-assign user queries to a different user. I have ran the DB Update statement in the database (as shown on the blog below).
http://mscrmblogger.com/2009/02/04/crm-4-userquery-privileges-for-system-administrators/
Here's my code:
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.AuthenticationType = AuthenticationType.AD;
token.OrganizationName = Request.Params["orgname"];
CrmService crmService = new CrmService();
crmService.Url = ConfigurationManager.AppSettings["WebServiceUrl"];
crmService.CrmAuthenticationTokenValue = token;
crmService.PreAuthenticate = true;
crmService.UseDefaultCredentials = false;
crmService.Credentials = new NetworkCredentials(username, password, domain);
SecurityPrincipal newowner = new SecurityPrincipal();
newowner.Type = SecurityPrincipalType.User;
newowner.PrincipalId = new Guid(userid);
TargetOwnedUserQuery query = new TargetOwnedUserQuery();
query.EntityId = new Guid(queryid);
AssignRequest assign = new AssignRequest();
assign.Assignee = newowner;
assign.Target = query;
AssignResponse assignResponse = (AssignResponse)crmService.Execute(assign);
When running this code, I get the below exceptions at the crmService.Execute().
SOAP Exception
Message: Server was unable to process request
Inner Detail: 0x8000404ff Cannot assign Offline Filters Platform
When running this for a couple of the user queries, I get a few slightly different exceptions. The majority of the user queries return the above/first exception shown above. A few return these different SOAP exceptions.
2) Inner Detail: 0x80048448 Cannot assign address book filters Platform
3) Inner Detail: 0x80040264 Cannot assign Outlook Filters Platform
As far as I know, we aren't using Offline Filters with our CRM product. We're also not using anything relating to Outlook integration.
The custom ASPX page is hosted the same server as our CRM and within a ISV folder. The authentication, sitemap customization, and (seemingly) every other piece is working correctly to integrate this as a custom page.
Any tips on how to troubleshoot this?
Thanks
Query to get the UserQueryID, @SystemUserId is passed in via populated dropdown box of users
SELECT [Name], [UserQueryId]
FROM [UserQueryBase]
WHERE [OwningUser] = @SystemUserId
ORDER BY [Name]
So we really need to know how you are getting the Guid of the UserQuery. If you can elaborate on that it would probably help. That said, I'll take a shot at answering.
Just because you are not using Outlook doesn't mean there will not be automatically generated Views and Filters in the database.
You need to check the UserQuery entity prior to doing the assignment to ensure it is not one of the types generating an error message. You may also wish to log these so you can investigate them further.
The value to check is userquery.querytype
which is a CrmNumber type. It will be an Enum type (use the SDK: SDK\Helpers\CS\CrmHelpers\enums.cs) that uses flags. Use the .HasFlag(integer)
to check to see if the attribute contains a flag for a specific type of query.
See the SDK for a list of potential query types.
You'll want to avoid doing assignment of queries designed for offline usage.