i have an issue: the error…` when creating a new record
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Expected non-empty Guid.Detail:
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
<ErrorCode>-2147220989</ErrorCode>
<ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Message>Expected non-empty Guid.</Message>
<Timestamp>2013-01-31T09:23:30.4406111Z</Timestamp>
<InnerFault i:nil="true" />
<TraceText>
The Code…` sets the fields to values. i have also tried
Pline.Id = new Guid();
Pline.Id = a; //(a is a guid ref to parent record)
Entity Pline = new Entity("bc_packlines");
if (b.Attributes.ContainsKey("mins_sum"))
{
BlockMins = ((Decimal)((AliasedValue)b["mins_sum"]).Value);
}
Pline.Attributes["bc_packlinesid"] = Pline.Id;
Pline.Attributes["bc_pack"] = a;
Pline.Attributes["bc_type"] = "948110004";
Pline.Attributes["bc_minutespurchased"] = BlockMins;
Pline.Id = a;
service.Create(Pline);
Any ideas please? Thanks
Some of that is a bit confusing, especially
You should not need to set the Id of your new entity explicitly so remove:
Edit: Also you say that
ais the Guid to a parent record – so how/why would you set as the PK of another record? That won’t work fullstop.Secondly, in this line
You are setting the value of the field
bc_packlinesidto an empty guid, as the Id of the record you are creating is not yet set. This means you are trying to get the entity to refer to itself? It doesn’t sound right to me but if it is, you will need to do this as a second step, afterSomething like
That is if that is even possible, I’m not sure if CRM will allow an entity to parent-child itself.