Reputation: 288
I'm developing a windows forms application & I've retrieved all the values from the look up by using the following code:
var value = item.GetAttributeValue<EntityReference>("attributename").Name;
Now comes the major task of assigning a value to the Lookup fields. When I tried to add the value it fails. I browsed in the internet and there is not much info about this. I could only find some Xrm.Page which is for web applications.
Can anyone of the experts please help on this & shred some light upon?
Upvotes: 0
Views: 88
Reputation: 2311
Create a new entity object, set the attribute values you want (in this case an EntityReference
) and then finally call Microsoft.Xrm.Sdk.IOrganizationService.Update
.
Create a new entity object
var entity = new Entity { Id = new Guid("recordId"), LogicalName = "entityName" };
Set attribute values
entity["attributeName"] = new EntityReference(new Guid("recordId"), "entityName");
Call update
service.Update(entity);
Upvotes: 3