2
我創建了新的實體。更新自定義工作流程活動中創建的記錄-CRM -C#
從那個實體我調用創建機會的自定義工作流活動實體。 它的工作原理,但另外我必須改變創造機會的一些領域。 (我必須添加機會產品,並且必須更改每個機會的價格清單)。
作爲一項測試,我嘗試在創建後更新帳戶字段,但它失敗了字段。當我在創建之前填充此帳戶字段時,它可以正常工作,所以它不是那樣的。 下面是部分代碼:
Entity entity = null;
if (context.InputParameters != null && context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
entity = (Entity)context.InputParameters["Target"];
}
else
{
entity = service.Retrieve(context.PrimaryEntityName, ((Guid)context.PrimaryEntityId), new ColumnSet(true));
}
Entity opportunity = new Entity("opportunity");
string name = entity.GetAttributeValue<string>("subject");
opportunity["name"] = name;
opportunityId = service.Create(opportunity);
EntityReference accountlookup = (EntityReference)entity.Attributes["ad_sendto"];
Guid accountId = accountlookup.Id;
opportunity["parentaccountid"] = new EntityReference("account", accountId);
service.Update(opportunity);
要重複,它創造的機會,但它不適用於更新工作,有沒有其他的辦法做到這一點,還是我在這裏有一些錯誤?
'機會[ 「parentaccountid」] = entity.Attributes [「ad_sendto 「];' 'service.Update(opportunityToUpdate);' 最後兩行,你的意思是'機會[」parentaccountid「]'或'opportunityToUpdate [」parenaccountid「]',befor更新? –
你是對的,複製粘貼錯誤,更新了答案。 – dynamicallyCRM