Показать сообщение отдельно
Старый 10.01.2018, 05:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
ievgensaxblog: D365FOE. How to override form data source field lookup method.
Источник: https://ievgensaxblog.wordpress.com/...lookup-method/
==============

A long time ago, I wrote a blog post explaining how to override form data source field methods. I skipped lookup, most popular method, because it did not work and logged a bug with MS hoping that it would be fixed soon. It took more time than I expected, but finally, it works!

Here is a small example how to override it. I’m going to use approach similar to previous post, full example is available on GitHub. Version I’m using is 7.3 PU13.

/// /// Handles events raised by SalesTable form./// public class SalesTableEventHandler{ /// /// Post event handler for SalesTable SalesLine Initialized event. /// /// /// [FormDataSourceEventHandler(formDataSourceStr(SalesTable, SalesLine), FormDataSourceEventType::Initialized)] public static void SalesLine_OnInitialized(FormDataSource _sender, FormDataSourceEventArgs _e) { var overrides = SalesTableFormExtensionOverrides::construct(); _sender.object(fieldNum(SalesLine, ItemId)).registerOverrideMethod(methodStr(FormDataObject, lookup), methodStr(SalesTableFormExtensionOverrides, ItemId_OnLookup), overrides); }}/// /// Contains methods which are used to override SalesLine data source field methods./// public class SalesTableFormExtensionOverrides{ protected void new() { } /// /// Constructs a new instance of SalesTableFormExtensionOverrides class. /// /// /// A SalesTableFormExtensionOverrides class. /// public static SalesTableFormExtensionOverrides construct() { return new SalesTableFormExtensionOverrides(); } /// /// Provides a lookup for the InventTable table /// /// /// The form string control object with which to perform the lookup. /// public void ItemId_OnLookup(FormStringControl _callingControl) { SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(InventTable), _callingControl); sysTableLookup.addLookupfield(fieldNum(InventTable, ItemId)); sysTableLookup.addLookupfield(fieldNum(InventTable, NameAlias)); sysTableLookup.performFormLookup(); }}As you may notice, signature of this method is different to signature of other methods, like validate or jumpRef. They accept FormDataObject as a parameter and lookup() accepts FormStringControl. It looks a bit inconsistent for me and we need to be extra careful here because you can register override method with any signature and get error in the run-time.




Источник: https://ievgensaxblog.wordpress.com/...lookup-method/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.