简体   繁体   中英

Adding value to LOOKUP field in microsoft dynamics crm 2011

I need to update a look up field in account using xrm services of microsoft dynamics crm 2011.

Need some ideas.Pls. Help

Lookup fields in CRM 2011 are EntityReference , this means you need to know the LogicalName of the entity the lookup is pointing and the Id of the record.

Assuming you are already connected to CRM (you can use simplified connection as this example: https://stackoverflow.com/a/15930366/2191473 )

you can set the lookup field using this syntax:

Entity recordToUpdate = service.Retrieve("contact", contactId, new ColumnSet(true));
recordToUpdate["parentcustomerid"] = new EntityReference("account", accountId);
service.Update(recordToUpdate);

you first get the record tu update, after set the lookup field with an EntityReference and after you save the record.

1) Download the Developer Toolkit for CRM 2011.

2) Follow the directions to develop and deploy a plugin solution

The toolkit contains templates for plugins similar to the one you require. Guido's answer for the actual lookup modification is correct.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM