【问题标题】:when associating an entity, its name property isn't initialized properly with the referencing entity关联实体时,其名称属性未与引用实体正确初始化
【发布时间】:2013-01-08 06:17:37
【问题描述】:

我遇到了自引用 1:N 关系的问题-
我正在尝试将实体 A(new_transaction 类型)与实体 B(相同类型)关联。
该关联工作正常(我已检查 DB-'new_relatedTransactionId' 列已正确更新)。
但是,名称列 ('new_relatedTransactionIdName') 设置为 NULL,导致表单显示一个空文本框...

我尝试了以下方法,但没有成功-
1.

var rel = new Relationship(relationshipName) {PrimaryEntityRole = EntityRole.Referenced};
EntityReferenceCollection relatedEntities = new EntityReferenceCollection();
relatedEntities.Add(relatedTransaction.ToEntityReference());
crmServiceContext.Associate(new_transaction.EntityLogicalName,sourceTransaction.Id,rel,relatedEntities);

2

sourceTransaction.lv_relatedtransactionid = relatedTransaction.ToEntityReference();
crmServiceContext.UpdateObject(sourceTransaction);

3

crmServiceContext.AddLink(sourceTransaction, new Relationship(relationshipName) { PrimaryEntityRole = EntityRole.Referenced }, relatedTransaction);

我尝试切换EntityRole.ReferencedEntityRole.Referencing,但仍然没有运气。
有人遇到过类似的问题吗?

【问题讨论】:

    标签: dynamics-crm-2011 dynamics-crm


    【解决方案1】:

    选项 2 是我创建这种关系的首选方法。

    字段'new_relatedTransactionIdName'没有存储在数据库中,你实际上是在查看一个SQL View。

    如果此字段为 null,则表明 new_relatedTransactionId 中 Guid 引用的实体记录的主字段为空。

    每个实体都有一个定义为主要字段的文本字段。该字段的值不一定是必填字段,因此最终可以为空白,它将显示在图像的文本框中。

    您没有定义特定于关系的此值,它是在创建和/或更新实体记录时创建的,并在关系中涉及该实体的任何地方使用。

    【讨论】:

    • 是的。您必须转到自定义 => 实体 => 主字段选项卡并查看要设置的字段。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-03-20
    • 1970-01-01
    • 1970-01-01
    • 2011-12-16
    • 2010-09-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多