I hope somone can help me further, as I'm really much stuck here. Im trying to add a contract line to my contract entity from a post-creat plugin. My code:
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);
For some reason I get the error that "Attribute: contractid cannot be set to NULL" which really stragnge because it actually does get the GUID for the contractid, as I checkd it on another field on another entity. I would really much appreciate if somone can help me out here. Thanks.