C# 检索另一个用户视图';获取XML属性

C# 检索另一个用户视图';获取XML属性,c#,.net,dynamics-crm-2011,C#,.net,Dynamics Crm 2011,我试图通过以下操作检索personal view的fetchxml(由向组织服务发出请求的用户以外的其他用户拥有): public static UserQuery RetrieveUserQuery(string userQueryName) { string xmlFetch = @"<fetch distinct='false' mapping='logical' output-format='xml-platform' ve

我试图通过以下操作检索personal view的fetchxml(由向组织服务发出请求的用户以外的其他用户拥有):

        public static UserQuery RetrieveUserQuery(string userQueryName)
        {

            string xmlFetch = @"<fetch distinct='false' mapping='logical' output-format='xml-platform' version='1.0'> 
                                    <entity name='userquery'>
                                        <attribute name='fetchxml'/>
                                        <filter type='and'>
                                            <condition attribute='name' value='{0}' operator='eq'/>
                                        </filter>
                                    </entity>
                                </fetch>";

            xmlFetch = string.Format(xmlFetch, userQueryName);

            try
            {
                var ent = Helper.XrmProxy.RetrieveMultiple(new FetchExpression(xmlFetch));

                if (ent.Entities.Count() == 0)
                    return null;
                if (ent.Entities.Count() > 1)
                    throw new Exception("More than one view with same name found!");

                return ent.Entities[0].ToEntity<UserQuery>();

            }
            catch
            {
                throw;
            }
        }
publicstaticuserqueryretrieveuserquery(字符串userQueryName)
{
字符串xmlFetch=@”
";
xmlFetch=string.Format(xmlFetch,userQueryName);
尝试
{
var ent=Helper.XrmProxy.RetrieveMultiple(新的FetchExpression(xmlFetch));
if(ent.Entities.Count()==0)
返回null;
if(ent.Entities.Count()>1)
抛出新异常(“找到多个同名视图!”);
返回ent.Entities[0].ToEntity();
}
抓住
{
投掷;
}
}
但我们似乎只能通过在组织服务上使用与拥有视图的凭据相同的凭据来实现这一点

真的是这样吗?有旁路吗


此方法始终返回null(检索到0个实体)。组织服务上使用的凭据是系统管理员,因此我认为即使未共享,我也可以访问它。

个人视图仅由用户拥有,直到与其他用户共享为止。即使系统管理员也无法访问另一个用户的个人视图

您可能会审核userquery创建,在代表当前用户上下文运行的插件中更新和删除消息,并将FetchXml保存在自定义实体中,以便您轻松查询。这很有用,尽管需求已更改,不再需要执行此操作,但我将使用系统视图。你可以提出这个答案,我会接受的。