Nov 8, 2013

How to get query through code ?

static  void  TestQuery(Args _args)
{
       AifInboundPort                 aifInboundPort;
       Query                               query;
       QueryBuildDataSource     queryBDS;
       QueryRun                         qr;
        ;
       query =  new Query(queryStr("AifInboundPortQuery"));
    // queryBDS = query.dataSourceTable(tablenum(AifInboundPort)); // Optional
       qr = new QueryRun(query);

       while (qr.next())
       {
          // aifInboundPort = qr.get(tableNum(AifInboundPort));
             aifInboundPort = qr.getNo(1);
             info(aifInboundPort.AosChannelId);
       }

}

Oct 24, 2013

How to get the address in single line


//BP Deviation documented
display Addressing CompanyAddress()
{
    str     singleLineAddr;
    ;

    for (j=0; j<10 j="j" p="p">    {
        if (j == 0 && strLine(CompanyInfo::find().Address, j))
        {
            singleLineAddr  +=  strLine(CompanyInfo::find().Address, j);
        }
        else if (strLine(CompanyInfo::find().Address, j))
        {
            singleLineAddr  +=  ', ' + strLine(CompanyInfo::find().Address, j);
        }
        else
        {
            break;
        }
    }

    return singleLineAddr;

}

Finding primary key in a table

The following job gives the name the primary field

DictTable dictTable;
DictField dictField;
;
dictTable = new SysDictTable(tableNum(TaxTrans));
dictField = new SysDictField(dictTable.id(), dictTable.primaryKeyField());
 info(dictField.name());