How to set value of lookup field in a new entity in CRM using C#
问题 I am trying to update a Lookup field in CRM via the following code. Create a new entity Person Person contains a lookup field HospitalOfBirth from another entity Hospital Value to be inserted: hospitalName I referenced from online articles and drafted my code below. Entity Person = new Entity("Person"); //do I set the value of the field by the following? Person.Attributes[Person.HospitalOfBirth] = hospitalName; Person.Attributes[Person.HospitalOfBirth] = new EntityReference("Hospital", Person