我希望有人能进一步帮助我,因为我真的很困在这里。我试图从创建后插件向我的合同实体添加合同行。我的代码:
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”的错误,这真的很奇怪,因为它实际上确实获得了 contractid 的 GUID,因为我在另一个实体的另一个字段上检查了它。如果有人能在这里帮助我,我将不胜感激。谢谢。