Adding value to LOOKUP field in microsoft dynamics crm 2011

六眼飞鱼酱① 提交于 2019-12-25 01:53:17

问题


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

Need some ideas.Pls. Help


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/22959421/adding-value-to-lookup-field-in-microsoft-dynamics-crm-2011

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!