Question

I'm trying to create a new custom entity record. I edited code here for this specific issue. My forced exception displays the correct opportunity id I am trying to write. The field "new_name" writes correctly to the new record but "new_field8" is always null in the record. I do not receive any compile or runtime errors. new_field8 is defined as uniqueidentifier. Please note that new_field8 is not the id of myentity, it is another guid field in the record.

Guid oppid = someEntity.Id;
throw new SystemException("oppid: " + oppid");

Entity myentity = new Entity("new_myentity");
myentity["new_name"] = "test";
myentity["new_field8"] = oppid;
Guid myentityId = service.Create(myentity);
Was it helpful?

Solution

Finally got a line that works! Hope it helps you too.

myentity["new_field8"] = new EntityReference("opportunity", new Guid(oppid.ToString())); 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top