我希望索莫能进一步帮助我,因为我非常困在这里。我正试图从一个后胶片插件中为我的合同实体添加一条合同线。 我的代码是:
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);
出于某种原因,我得到一个错误,即“归属:合同不能设定为 NULL ”, 因为它实际上确实得到了合同的图形用户界面D, 正如我在另一个实体的另一字段上检查的那样。 如果索莫能帮助我, 我将非常感激。 谢谢 。