Thursday, October 22, 2009

Adding Array Field Range on QueryBuildDataSource

At some point in your miserable life, you will need to add a range to a QueryBuildDataSource to filter on an array field such as dimension.

 

Here is an example of a code to do it

 

public client static void lookupValidParentProj(FormStringControl ctrl)

{

    Query                query          =  new Query();

    QueryBuildDataSource queryBuildDataSource;

    ;

 

    queryBuildDataSource = query.addDataSource(tablenum(ProjTable));

     //this is how to add a normal range

    queryBuildDataSource.addRange(fieldnum(ProjTable, Template)).value(queryValue(NoYes::Yes));

    //this is how to add an a range on a particular array field. In this instance, the third field in the array

    queryBuildDataSource.addRange(FieldId2Ext(FieldNum(SalesLine, Dimension),3)).value(queryValue(SysQueryRangeUtil::currentEmplDepartment()));

 

    sysTableLookup.parmQuery(query);

    sysTableLookup.performFormLookup();

}

 

No comments:

Post a Comment