有时我需要在CRM中删除具有关联的重复记录。在这些情况下,我必须重新分配这些协会。相关实体菜单允许我逐个检查记录是否在与其相关的任何实体中具有关联。这迫使我扫描许多相关实体。有没有更快捷的方法来查看记录的所有关联?
答案 0 :(得分:4)
您可以创建一个新的记录表单,在单个页面上显示所有相关记录作为子网格 - 可以节省几次点击。
这种方法很少考虑:
答案 1 :(得分:1)
不是通过CRM用户界面,但如果你是一个SQL向导,你可能会想出一些花哨的查询来做到这一点。然后,如果您想更进一步,可以通过点击来部署SSRS报告。
如果您正在处理联系人或帐户等OOB记录,您还应该考虑OOB Merge这样的场景 - 因为这会自动为您重新显示子记录(授予它会将所有子记录重新显示给新的“master”) “记录,但通常是预期的功能,所以它适用于大多数情况下)。
答案 2 :(得分:0)
如果您需要重新分配所有关联,这将有效:
您刚刚克隆了一条记录,而新记录将包含旧记录中的所有关联。
答案 3 :(得分:0)
通过在SQL中查询实体的过滤视图,可以找到所有N:1关系,但最快的解决方案就是使用内置于CRM的合并功能,如建议的那样。它不会删除欺骗,但会将其停用并将您指定的所有内容分配给“主”记录。从那里,您可以删除已停用的记录。
答案 4 :(得分:0)
我知道这个问题很旧,但我创建了一个控制台应用程序,它将显示相关记录的相关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;
}
}