Dynamics AX2012 Custom Lookup on a Dialog

AX2012 在对话框上自定义查找.

DilaogLookup ckass

ckass Deckaration

Here the class declaration, don’t forget to extend RunBase.

class DialogLookup extends RunBase
{
 
}

Methods:

Main

Nothing special here either, just get a new instance from your class, to be able to run it later on.

static void main(Args _args)
{
    DialogLookup            dialogLookup = new DialogLookup();
 
    if (dialogLookup.prompt())
    {
        dialogLookup.run();
    }
}

Our dialog

This is where the fun starts. You simply want to get the control from your field, then you call the registerOverrideMethod(…) and as parameter you provide your class name (in this case, the class we are actually writing here) and the method name (this does not have to be lookup!).

protected Object dialog()
{
    Dialog                      dialog;
    FormStringControl           control;
    DialogField                 fieldLookup;
 
    dialog = super();
 
    // Dialog Title
    dialog.caption("Aif Adapter");
 
    // Field - EDT, Label
    fieldLookup = dialog.addField(extendedTypeStr(AifAdapterName), "AifAdapterName:");
 
    // Get control
    control = fieldLookup.control();
 
    // Override lookup method
    control.registerOverrideMethod(methodStr(FormStringControl, lookup), 
                                   methodStr(DialogLookup /* Class name */, 
                                             lookup /* Method name*/), this);
 
    return dialog;
}

The custom lookup

In the last step we will just set up a “normal” (don’t forget the FormStringControl!) lookup method.

public void lookup(FormStringControl _control)
{
    Query                   query = new Query();
    QueryBuildDataSource    queryBuildDataSource;
    SysTableLookup          sysTableLookup = SysTableLookup::newParameters(tableNum(AifAdapter), 
                                                                           _control);
 
    // Create lookup for AifAdapter's Name and AdapterClassId
    sysTableLookup.addLookupField(fieldNum(AifAdapter, Name));
    sysTableLookup.addLookupField(fieldNum(AifAdapter, AdapterClassId));
 
    // Setup query
    queryBuildDataSource = query.addDataSource(tableNum(AifAdapter));
    sysTableLookup.parmQuery(query);
 
    // Perform lookup
    sysTableLookup.performFormLookup();
}

And this is what it looks like:

Just hit F5 and run your class.

 

AX2012 Dialog Custom Lookup Closed

The custom lookup provides us the class id. If I recall it right, the standard AX would provide the EDT Type.

AX2012 Dialog Custom Lookup Open

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值