To create a lookup on the values of a single financial dimension, follow the following steps:
- create a new field with ‘DimensionValue’ as ExtendedDataType
- On the form, in the datasource, override the lookup method of the newly added field
- copy one of the following two code snippets (the first is better because it calls the standard class)
public void lookup(FormControl _formControl, str _filterStr)
{
//super(_formControl, _filterStr);
Args args;
FormRun formRun2;
DimensionAttribute dimensionAttribute;
FormStringControl ctrl = _formControl as FormStringControl;
select dimensionAttribute
where dimensionAttribute.Name == 'MyDimensionName';
args = new Args();
args.record(dimensionAttribute);
args.caller(_formControl);
args.name(formstr(DimensionLookup));
formRun2 = classfactory.formRunClass(args);
formRun2.init();
ctrl.performFormLookup(formRun2);
}
public void lookup(FormControl _formControl, str _filterStr)
{
SysTableLookup sysTableLookup;
Query query;
QueryBuildDataSource qbdsDimensionFinancialTag;
QueryBuildRange qbrFinancialTagCategory;
#define.CustomFinancialDimension('MyDimensionName')
query = new Query();
qbdsDimensionFinancialTag = query.addDataSource(tableNum(DimensionFinancialTag));
qbrFinancialTagCategory = qbdsDimensionFinancialTag.addRange(fieldNum(DimensionFinancialTag, FinancialTagCategory));
qbrFinancialTagCategory.value(strFmt("%1", DimensionAttribute::findByName(#CustomFinancialDimension, false).financialTagCategory()));
sysTableLookup = sysTableLookup::newParameters(tableNum(DimensionFinancialTag), _formControl,true);
sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Value), true);
sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Description));
sysTableLookup.addSelectionField(fieldNum(DimensionFinancialTag, FinancialTagCategory));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}