In this article, giving an example for defining the lookup for dimensions in simple way.
This example will cover only for user Defined dimensions.
For this
1) Created a form and added two string controls.
2) Named as
Control: Name: Dimensionlist, Auto declaration – Yes
Control: Name: DimValues
3) Override the lookup method for Dimensionlist
public void lookup()
{
Query query;
SysTableLookup sysTableLookup;
super();
sysTableLookup = SysTableLookup::newParameters(tableNum(DimensionAttribute), this);
sysTableLookup.addLookupfield(fieldNum(DimensionAttribute, Name));
query = new Query();
query.addDataSource(tableNum(DimensionAttribute)).
addRange(fieldNum(DimensionAttribute, Type)).
value(queryValue(DimensionAttributeType::CustomList));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
------------------------------------------------------------------------------
4) Override the lookup method for DimValues
public void lookup(){DimensionAttribute dimensionAttribute;DimensionAttributeDirCategory dimAttributeDirCategory;Query query = new Query();SysTableLookup sysTableLookup;dimensionAttribute = DimensionAttribute::findByName(Dimensionlist.text());super();// Only user defined dimensions will have a financial tag categoryif (dimensionAttribute.Type == DimensionAttributeType::CustomList){select firstonly DirCategory from dimAttributeDirCategory where dimAttributeDirCategory.DimensionAttribute == dimensionAttribute.RecId;sysTableLookup = SysTableLookup::newParameters(tableNum(DimensionFinancialTag), this);// Add name field to be shown in the lookup form.sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Value));sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Description));query = new Query();query.addDataSource(tableNum(DimensionFinancialTag)).addRange(fieldNum(DimensionFinancialTag, FinancialTagCategory)).value(queryValue(dimAttributeDirCategory.DirCategory));sysTableLookup.parmQuery(query);// Perform the lookup.sysTableLookup.performFormLookup();}}
No comments:
Post a Comment