最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

Custom lookup for Financial Dimension D365 for Finance and Operations (Dynamics Ax 7)

网络文摘 alirazazaidi 5653浏览 0评论

Suppose we have to display all values in “Cost Center” financial dimension in custom lookup. For this post I used unbound field.

So first step is we need we need a text box. So drop a control of type “String” ( “Traditionally it is StringEdit Control”).

Right click on “OnLookup”event and click on “copy event handler method”.

Now Add a new class in project update its same as required. For this current post I renamed the Class as FromControlEventHandler

In Class opening closing brackets paste the event code, this code we copied in previous step.

It will something like
[FormControlEventHandler(formControlStr(FrmTestDetail, FormStringControl1), FormControlEventType::Lookup)]
public static void FormStringControl1_OnLookup(FormControl sender, FormControlEventArgs e)
{

}

I update with following code snippet, If you are seasonal Ax consultant or developer you found this very similar.

/// [FormControlEventHandler(formControlStr(FrmTestDetail, FormStringControl1), FormControlEventType::Lookup)]
public static void FormStringControl1_OnLookup(FormControl sender, FormControlEventArgs e)
{
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange qbrForAccount;
SysTableLookup sysTableLookup;
// DimType dimType;
DimensionAttribute dimensionAttribute;
// SysTableLookup::newParameters(tableNum(CustTable),sender);
sysTableLookup = SysTableLookup::newParameters(tableNum(OMOperatingUnit),sender,true);
sysTableLookup.parmUseLookupValue(false);
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, OMOperatingUnitNumber));
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, Name));
queryBuildDataSource = query.addDataSource(tableNum(OMOperatingUnit));
queryBuildDataSource.addSortField(fieldnum(OMOperatingUnit,OMOperatingUnitNumber));
queryBuildDataSource.addRange(fieldNum(OMOperatingUnit, OMOperatingUnitType)).value(int2str(any2int(OMOperatingUnitType::OMCostCenter)));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();

FormControlCancelableSuperEventArgs ce = e as FormControlCancelableSuperEventArgs;
//cancel super() to prevent error.
ce.CancelSuperCall();

}

There is no need to add different classes for each event. I found you can copy and write events of different controls in single class. Every interesting, If I right click on “Find Event Handler”

it will show me the event Handler reference as

Now let see what will our output. So I pressed Ctrl+F5 so form run without debugging. And forms open, But Here is difference, We need edit button to turn form in edit mode,
Cheers, After pressing Edit Button my unbound custom lookup with Specific financial dimension works fine.

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址