I am using Microsoft.PowerPlatform.Dataverse.Client.Dynamics package to update CRM entity.
to update a normal field,
entity.Attributes["ecg_proposal_url"] = sendURL ;
await client.UpdateAsync(entity);
works fine. but when I try the same with a navigation field (pointing to user) , I get error:
"CRM do not support direct update of Entity Reference properties, Use Navigation properties instead" The search did not show any example. Also the DOCs are very slim. How do I update it with field name "_ecg_proposal_written_by_value" ? Thank you. The code that causes the error is:
entity.Attributes["_ecg_proposal_written_by_value"] = writtenByID;
Or
entity.Attributes["ecg_proposal_written_by"] = writtenByID;
it should have a user ID
a lookup field needs to specify the table associated with it.
With the C# SDK you need to assign a EntityReference
object.
Something like:
entity["ecg_proposal_written_by"] = new EntityReference("systemuser", writtenByID);
assuming the lookup points to the systemuser (User) table.
Note that with the C# SDK you need to use the logical name of the field (ecg_proposal_written_by
) and not the name used with Web API / OData 4.0 syntax (in your case _ecg_proposal_written_by_value
)