Dynamics crm 2011 在MS Dynamics CRM中是否有快速查看所有关联记录的方法?

Dynamics crm 2011 在MS Dynamics CRM中是否有快速查看所有关联记录的方法?,dynamics-crm-2011,dynamics-crm,crm,dynamics-crm-2013,microsoft-dynamics,Dynamics Crm 2011,Dynamics Crm,Crm,Dynamics Crm 2013,Microsoft Dynamics,有时我需要删除CRM中具有关联的重复记录。在这种情况下,我必须重新分配这些关联。related entities(相关实体)菜单允许我逐个检查记录是否在与其相关的任何实体中存在关联。这迫使我扫描许多相关的实体。有没有更快捷的方法查看记录的所有关联?不是通过CRM UI,但是如果您是SQL向导,您可能会想出一些奇特的查询来实现这一点。然后,如果您想更进一步,可以通过单击来部署SSRS报告 你也应该考虑这样的OOB合并,如果你正在处理OOB记录,比如联系人或帐户——因为这会自动为你重新记录子记录(当

有时我需要删除CRM中具有关联的重复记录。在这种情况下,我必须重新分配这些关联。related entities(相关实体)菜单允许我逐个检查记录是否在与其相关的任何实体中存在关联。这迫使我扫描许多相关的实体。有没有更快捷的方法查看记录的所有关联?

不是通过CRM UI,但是如果您是SQL向导,您可能会想出一些奇特的查询来实现这一点。然后,如果您想更进一步,可以通过单击来部署SSRS报告


你也应该考虑这样的OOB合并,如果你正在处理OOB记录,比如联系人或帐户——因为这会自动为你重新记录子记录(当然,它会将所有子记录重置为新的“主”记录,但这通常是预期的功能,所以它在大多数情况下是有效的)。p> 您可以制作一个新的记录表单,将所有相关记录显示为一个页面上的子网格,这样可以节省几次点击

这种方法的几个考虑因素:

  • 你可能会得到一个很长的表格
  • 你可能会变成一个丑陋的人
  • 根据您的CRM版本和显示的网格数量,您可能必须单击以加载子网格(尽管可以使用JavaScript来完成此操作)

如果需要重新分配所有关联,这将起作用:

  • 创建新记录(相同的名称/标题)
  • 合并这两条记录
  • 选择“旧”记录中的所有数据,并使新记录成为主记录(主记录将是新记录并继承所有下级记录的子记录)
  • 由于“旧”记录将被停用,您需要再次激活它

您刚刚克隆了一条记录,新记录将具有旧记录的所有关联。

所有N:1关系都可以通过查询SQL中实体的筛选视图找到,但最快的解决方案只是使用CRM中内置的合并功能,如建议的那样。它不会删除复制,但会将其停用并分配您为“主”记录指定的所有内容。从那里,您可以删除已停用的记录。

我知道这个问题很老,但我创建了一个控制台应用程序,它将显示相关记录的相关GUID和逻辑名称。目前无法处理多对多关系,因为我的应用程序不需要它。它可以简化我可以显示到唱片的链接,但这不是我需要的

static void Main(string[] args)
    {
        IOrganizationService OrganizationService = null;

        string sourceBaseUrl = "http://server/org";

        OrganizationService = CrmHelpers.GetService(sourceBaseUrl);

        //OrganizationService = CrmHelpers.GetService("sock-devcrm2015", "acs-training", "80", "http", "username", "password", "domain");

        //query for relationships for the desired record
        //need to get GUID and LogicalName
        Entity get = new Entity();

        Console.WriteLine(string.Format("What is the Logical Name?"));
        Console.Write("String: ");

        get.LogicalName = Console.ReadLine();

        Console.WriteLine(string.Format("What is the GUID?"));
        Console.Write("GUID: ");

        get.Id = Guid.Parse(Console.ReadLine());

        RetrieveEntityRequest retrieveEntity = new RetrieveEntityRequest
        {
            EntityFilters = EntityFilters.Relationships,
            LogicalName = get.LogicalName
        };
        RetrieveEntityResponse response = (RetrieveEntityResponse)OrganizationService.Execute(retrieveEntity);

        var oneToN = response.EntityMetadata.OneToManyRelationships;
        var nToOne = response.EntityMetadata.ManyToOneRelationships;

        foreach (var relationship in oneToN)
        {
            string fetch = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
                                  <entity name='" + relationship.ReferencingEntity + @"'>
                                    <filter type='and'>
                                        <condition attribute='" + relationship.ReferencingAttribute + @"' operator='eq' value='" + get.Id.ToString() + @"' />
                                    </filter>
                                  </entity>
                                </fetch>";


            var results = OrganizationService.RetrieveMultiple(new FetchExpression(fetch));

            foreach (var result in results.Entities)
            {
                Console.WriteLine(string.Format("1:N || GUID: {0} LogicalName: {1}", result.Id, result.LogicalName));
            }
        }
        Console.WriteLine("----------------------------------------------------------");
        Console.WriteLine("----------------------------------------------------------");
        foreach (var relationship in nToOne)
        {
            string fetch = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
                                  <entity name='" + relationship.ReferencedEntity + @"'>
                                    <link-entity name='"+relationship.ReferencingEntity+ @"' from='"+relationship.ReferencingAttribute+@"' to='"+relationship.ReferencedAttribute+@"' alias='a'>
                                        <filter type='and'>
                                            <condition attribute='" + get.LogicalName+ @"id' operator='eq' value='" + get.Id.ToString() + @"' />
                                        </filter>
                                    </link-entity>
                                  </entity>
                                </fetch>";


            var results = OrganizationService.RetrieveMultiple(new FetchExpression(fetch));

            foreach (var result in results.Entities)
            {
                Console.WriteLine(string.Format("N:1 || GUID: {0} LogicalName: {1}", result.Id, result.LogicalName));
            }
        }

        Console.Write("END");
        Console.ReadLine();
    }


class CrmHelpers
{
    public static IOrganizationService GetService(string baseUrl)
    {
        ClientCredentials credentials = new ClientCredentials();
        credentials.Windows.ClientCredential = CredentialCache.DefaultCredentials.GetCredential(new Uri(baseUrl), "negotiate");


        Uri endpoint = new Uri(string.Format("{0}/XRMServices/2011/Organization.svc", baseUrl));
        OrganizationServiceProxy service = new OrganizationServiceProxy(endpoint, null, credentials, null);
        service.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
        return service;
    }
}
static void Main(字符串[]args)
{
IOOrganizationService OrganizationService=null;
字符串sourceBaseUrl=”http://server/org";
OrganizationService=CrmHelpers.GetService(sourceBaseUrl);
//OrganizationService=CrmHelpers.GetService(“sock-devcrm2015”、“acs培训”、“80”、“http”、“用户名”、“密码”、“域”);
//查询所需记录的关系
//需要获取GUID和LogicalName
实体get=新实体();
Console.WriteLine(string.Format(“逻辑名称是什么?”);
Console.Write(“字符串:”);
get.LogicalName=Console.ReadLine();
Console.WriteLine(string.Format(“GUID是什么?”);
控制台。写入(“GUID:”;
get.Id=Guid.Parse(Console.ReadLine());
RetrieveEntityRequestRetrieveEntity=新的RetrieveEntityRequest
{
EntityFilters=EntityFilters.Relationships,
LogicalName=get.LogicalName
};
RetrieveEntityResponse响应=(RetrieveEntityResponse)OrganizationService.Execute(retrieveEntity);
var oneToN=response.EntityMetadata.OneToManyRelationships;
var nToOne=response.EntityMetadata.manytonerelationships;
foreach(oneToN中的var关系)
{
字符串获取=@“
";
var results=OrganizationService.RetrieveMultiple(新的FetchExpression(fetch));
foreach(results.Entities中的var结果)
{
WriteLine(string.Format(“1:N | | GUID:{0}逻辑名称:{1}”,result.Id,result.LogicalName));
}
}
Console.WriteLine(“------------------------------------------------------------------”;
Console.WriteLine(“------------------------------------------------------------------”;
foreach(nToOne中的var关系)
{
字符串获取=@“
";
var results=OrganizationService.RetrieveMultiple(新的FetchExpression(fetch));
foreach(results.Entities中的var结果)
{
WriteLine(string.Format(“N:1 | | GUID:{0}逻辑名称:{1}”,result.Id,result.LogicalName));
}
}
控制台。写入(“结束”);
Console.ReadLine();
}
类帮助者
{
公共静态IOR组织服务GetService(字符串baseUrl)
{
ClientCredentials=新的ClientCredentials();
credentials.Windows.ClientCredential=CredentialCache.DefaultCredentials.GetCredential(新Uri(baseUrl),“协商”);
Uri端点=新Uri(string.Format(“{0}/XRMServices/2011/Organization.svc”,baseUrl));
OrganizationServiceProxy服务=新的OrganizationServiceProxy(端点,null,凭据,null);
service.ServiceConfiguration.CurrentServiceEnd