Add empty check on ToEntityReference method
Add this Guid.Empty check and return null if empty.
Reason:
EntityReference account = new Account();
This should assign null but instead it assigns an EntityReference with Guid.Empty. This throws an error when trying to Save.
The error can be resolved if it assigned null as EntityReference instead.
public EntityReference ToEntityReference()
{
if (Id == Guid.Empty) return null;
return new EntityReference(LogicalName, Id)
{
RowVersion = RowVersion
};
}
3
votes
Ahash Sritharan
shared this idea