AXForum  
Go Back   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Forgotten Your Password?
Register Forum Rules FAQ Members List Today's Posts Search

 
 
Thread Tools Search this Thread Display Modes
Old 10.01.2018, 05:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,644 / 848 (80) +++++++
Join Date: 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, напишите личное сообщение администратору.
 

Similar Threads
Thread Thread Starter Forum Replies Last Post
NAV Team: How to: Enable Import/Export of Bank or Payroll Files Using the Data Exchange Framework Blog bot Dynamics CRM: Blogs 0 18.10.2013 02:33
dynamicsaxtraining: Vendor returns Blog bot DAX Blogs 0 11.10.2012 00:11
dax-lessons: How to find out the source of data on SSRS reports [AX 2012] Blog bot DAX Blogs 0 01.06.2012 19:11
CRM DE LA CREME! Some more useful javascripts for MS CRM Blog bot Dynamics CRM: Blogs 0 04.05.2010 11:05
gatesasbait: How to define a custom lookup form for an extended datatype Blog bot DAX Blogs 0 09.07.2008 22:05

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Рейтинг@Mail.ru
All times are GMT +3. The time now is 01:48.
Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Contacts E-mail, Advertising.