【Dynamics365】Plugin EntityReferenceによる検索フィールドの設定
コンストラクタ
EntityReference reference = new EntityReference( <Entityの論理名>, <レコードのGUID>)
取引先企業取得
Entity account;
Guid opportunityid = new Guid(((EntityReference)contextentity.Attributes[“new_opportunity"]).id).ToString());
Entity opportunity = service.Retrieve("opportunity", opportunityid, new ColumnSet());
if( opportunity.Attributes.Contains("parentaccountid"))
{
Guid accountid = new Guid(((EntityReference)opportunity.Attributes[“parentaccountid"]).id).ToString());
account = service.Retrieve("account", accountid, new ColumnSet());
}
検索フィールドの設定
contextentity.Attributes["lookupentity"] = new EntityReference("account", accountid);