我希望somone能夠進一步幫助我,因爲我真的被困在這裏。我試圖從post-creat插件添加合同行到我的合同實體。我的代碼:Add Contract Line to Contract CRM 2011
Guid c_Id = (Guid)entity.Attributes["contractid"];
DateTime start = (DateTime)entity["activeon"];
DateTime end = (DateTime)entity["expireson"];
Money money = new Money();
money.Value = 0;
//Set Instance for Contract Line
Entity ContractLine = new Entity();
ContractLine.LogicalName = "contractdetail";
//Create Contract Line for the Contract
ContractLine["title"] = "PLUGIN FIRED";
ContractLine["activeon"] = start;
ContractLine["expireson"] = end;
ContractLine["totalallotments"] = 1;
//ContractLine["customerid"] = entity["customerid"];
//ContractLine["productid"] = entity["productid"];
ContractLine["price"] = money;
ContractLine["contractid"] = c_Id;
service.Create(ContractLine);
出於某種原因,我得到的錯誤「屬性:contractid不能設置爲NULL」,這真的stragnge,因爲它實際上沒有得到的GUID contractid,因爲我checkd而在另一場關於另一個實體。如果somone能幫助我,我真的很感激。謝謝。
非常感謝你布恩,欣賞它非常適合我。我必須將其更改爲ContractLine [「contractid」] =新的EntityReference(「contract」,c_Id)。 –