Associate——关联两条记录

1,如果一个实体的FORM中包含另下个实体类型的字段,直接将关联的实体的字段指向被关联实体的EntityReference就OK了
2,如果一个实体与另一个实体FORM中都没有包含相应的字段,而只是出现在左侧的导航中,则应调用AssociateEntitiesRequest将两者关联起来
AssociateRequest teamToProfile = new AssociateRequest

{

    Target = new EntityReference(FieldSecurityProfile.EntityLogicalName, _profileId),

    RelatedEntities = new EntityReferenceCollection

    {

        new EntityReference(Team.EntityLogicalName, _teamId)

    },

    Relationship = new Relationship("teamprofiles_association")

};



// Execute the request.

_serviceProxy.Execute(teamToProfile);

3,还有一类是系统定义好的关系实体,如商机产品,报价单产品,订单产品等,这种的只需要在创建的时候给相应的opportunityid,quoteid等字段赋好值,则会自动建立关联,如果没给这些字段,会则报错“The parent id is missing”

你可能感兴趣的:(SSO)