0
所以這裏是一件事:我創建了一個自定義實體「new_ligneContrat」,它與另一個自定義實體「new_produit」具有一對多關係 。相關活動記錄
這裏的目標是:當創建「new_ligneContrat」的新記錄時,它必須在它之前獲得「new_ligneContrat」的「new_produit」記錄。該插件是建立在「new_ligneContrat。
我在想,如果FetchExpression +最後的()可以做到這一點,但現在我還沒有找到妥善的解決辦法...提前
謝謝!
EDIT1:我們決定去一個到n的關係,所以我做了以下內容:
QueryExpression query = new QueryExpression();
query.EntityName = "new_produit"; query.ColumnSet = new ColumnSet("new_produitid"); Relationship relationship = new Relationship(); relationship.SchemaName = "new_new_lignecontrat_new_produit"; RelationshipQueryCollection relatedEntity = new RelationshipQueryCollection(); relatedEntity.Add(relationship, query); RetrieveRequest request = new RetrieveRequest(); request.RelatedEntitiesQuery = relatedEntity; request.ColumnSet = new ColumnSet("new_lignecontratid"); request.Target = new EntityReference { Id = first.Id, LogicalName = first.LogicalName }; RetrieveResponse response = (RetrieveResponse)service.Execute(request);
if (((DataCollection<Relationship, EntityCollection>)(((RelatedEntityCollection)(response.Entity.RelatedEntities)))).Contains(new
> Relationship("new_new_lignecontrat_new_produit")) &&
> ((DataCollection<Relationship,
> EntityCollection>)(((RelatedEntityCollection)(response.Entity.RelatedEntities))))[new
> Relationship("new_new_lignecontrat_new_produit")].Entities.Count > 0)
> {
> response.Results.Remove("new_produitid");
> response["new_lignecontratid"] = new EntityReference(target.LogicalName, target.Id);
是正確的嗎?
感謝彼得!最終我們決定採取一種n對n的關係,所以我做了以下工作: – MademoiselleLenore 2011-12-19 18:24:25