Tuesday, March 22, 2016

How to create multiple values in query range

You can create multiple values in query range from x++, where the code is:

QueryBuildDataSource qbds = q.dataSourceTable(TableId);
QueryBuildRange qbr;
while (...)
{
    qbr = qbds.addRange(fieldNum(TableId, FieldId));    qbr.value(queryValue(TableId.fieldId));
}
QueryBuildRange qbr = q.dataSourceTable(TableId).addRange(fieldNum(TableId, FieldId));
container c;
while (...)
{
    c+= queryValue(TableId.FieldId);
}
qbr.value(con2str(c));

Tuesday, March 15, 2016

How to override form datasource with another query

You can override form datasource with another (filtered) query.

You can put the code in datasource.executeQuery()

public void executeQuery()
{
    FormDataSource fds;
    ;
    //info(strFmt('1--%1', this.query().toString()));
    queryClass.executeQuery();
 
    fds = this.formRun().dataSource();
    fds.query(queryClass.parmQuery());
 
    //info(strFmt('1.1--%1', fds.query().toString()));
    //info(strFmt('2--%1', queryClass.parmQuery().toString()));
    super();
}

Where the "queryClass" is a class that create a filtered query.

Wednesday, March 9, 2016

How to comparing 2 field in AOT Query

The rules for creating query range value expressions are:
  • Enclose the whole expression in parentheses.
  • Enclose all subexpressions in parentheses.
  • Use the relational and logical operators available in X++.
  • Only use field names from the range's data source.
  • Use the dataSource.field notation for fields from other data sources in the query.


Tuesday, March 8, 2016

How to open FilePath EDT on form

If the filepath dialog is not opening on Form, U have to add below method on form (AOT > MyForm > Method > filePathLookupTitle)

public str filePathLookupTitle()
{
    return 'Import folder';
}

Sunday, March 6, 2016

How to create AOT object lookup

static void lookupAOTTables(FormStringControl _ctrl)
{
   SysTableLookup sysTableLookup =   SysTableLookup::newParameters(tablenum(UtilidElements), _ctrl);
   Query query = new Query();
   QueryBuildDataSource queryBuildDataSource;
   QueryBuildRange qbrType;
   ;
   sysTableLookup.addLookupfield(fieldnum(UtilidElements, Id));
   sysTableLookup.addLookupfield(fieldnum(UtilidElements, Name));

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

   qbrType= queryBuildDataSource.addRange(fieldnum(UtilidElements, RecordType));
   qbrType.value(SysQuery::value(UtilElementType::Table));

   sysTableLookup.parmQuery(query);
   sysTableLookup.performFormLookup();
}