Dynamics CRM 2011 - How to relate two different entities

£可爱£侵袭症+ 提交于 2020-01-06 07:32:30

问题


I have two different custom entities. The first one (payment) I create manually using a form. When the payment is created it executes a plugin that will create one or more vouchers. The plugin creates the voucher without a problem. The problem is when I go to the payment and click on vouchers, I don't see the voucher I just created listed. If I go look at all the vouchers I can see the one I just created. There is a 1 to many relationship from payment to voucher. What do I need to do in my plugin for the entities to be related?

Thanks


回答1:


Sounds like you just haven't setup the relationship back to the triggering payment when you create the voucher.

Given the 1:N relationship and since you're creating the voucher in the context of a payment plugin you can set the lookup on the voucher to the payment for which the plugin is currently executing (target).

new_voucher.new_paymentid = new EntityReference(...);

new_paymentid is the lookup attribute on voucher (obviously it'll be called something else in your case). For the EntityReference you'll need to define the EntityName and Id of the product, which you can read from the target.



来源:https://stackoverflow.com/questions/15510730/dynamics-crm-2011-how-to-relate-two-different-entities

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