Mar 23, 2015

Syntax of Try {} catch {} for updation in X++

void clicked()
{

#OCCRetryCount   

#task;  

super();

try

     // logic
}
catch (Exception::Deadlock)

{
      retry;

}
catch (Exception::UpdateConflict)

{
       if (appl.ttsLevel() == 0)

      {
           if (xSession::currentRetryCount() >= #RetryNum)

          {
                throw Exception::UpdateConflictNotRecovered;

          }
      else

     {
           retry;

     }
}
else

{
     throw Exception::UpdateConflict;

}
}
catch (Exception::Error)

{
       throw error("Label");

}
    Table_ds.research();

}

Mar 10, 2015

How to get the query range values through X++ code

static void testQuery(Args _args)
{
Query q;
QueryRun qr;
QueryBuildRange qbr;
str s;
custTrans custTran;
int cnt, i;
queryFilter queryFilter;
;

q = new Query(queryStr(CustOpenInvoicesListPage)); // This is AOT query

qr = new QueryRun(q);

qr.prompt(); // This prompt's the dialog

cnt = qr.query().dataSourceTable(tablenum(custTrans)).rangeCount();

for (i=1 ; i<=cnt; i++)
{
qbr = qr.query().dataSourceTable(tablenum(custTrans)).range(i);
info(strfmt("Field added in Range %1, Range value %2",qbr.AOTname(),qbr.value()));
}

while(qr.next())
{
custTran = qr.get(tableNum(custTrans));
info(strFmt("%1 ---- %2 ",custTran.AccountNum,custTran.TransType));
}
}

Mar 9, 2015

How to get integers from X++ string value

static void intCheck(Args _args)
{
#define.lineIncrement(1)
int64 lineConfirm;
str _text;
str _lineConfirm = 'ECM-00451';

lineConfirm = str2Int64(strKeep(_lineConfirm, "0123456789"));

_text = strRem(_lineConfirm, strFmt("%1",lineConfirm));

lineConfirm = lineConfirm+#lineIncrement;
_lineConfirm = _text+ strFmt("%1",lineConfirm);

info(strFmt("%1",_lineConfirm));
}