Skip to main content


Showing posts from April, 2017

AX 2012: Excel import/Converting the excel cells value to AX type

The below code helps when converting the excel cells type (variant) to actual AX type.
Below example shows how we can trigger the method:
invoiceNumber = this.formatValue(Types::String,cells.item(row, 1).value());

publicanytype formatValue(     Types _types,     COMVariant _variant) {     #TimeConstants     FreeText excelText;     Qty realValue;     Integer intValue;     TimeHour24 timeHour24;
switch (_types)     { case Types::UtcDateTime : // Time switch (_variant.variantType())             { case COMVariantType::VT_R4 :                 realValue = _variant.float(); break;
case COMVariantType::VT_R8 :                 realValue = _variant.double(); break;
case COMVariantType::VT_DECIMAL :                 realValue = _variant.decimal(); break;

AX 2012: Automatically log off the user sessions

Hello guys J
Today I thought of sharing the code where the user AX sessions which doesn’t belong to admin role will automatically shut down if it’s running for more than 8 hours.
The same can be pasted in batch class to be run as batchable.

publicvoid autoUserLogOff() {     SecurityUserRole        securityUserRole;     SecurityRole            securityRole; container               usersList;     SysClientSessions       sysUserSession; utcDateTime             dateTime, dateTimeLocal; TimeOfDay               totalHours;     SysUsersTerminate       usersTerminate;     SysUserInfo             userInfo; str                     timeValue;
    #define.AOTName('-SYSADMIN-')     #define.Admin('Admin')
    dateTime = DateTimeUtil::newDateTime(systemDateGet(), timeNow());
whileselect Id from userInfo where  userInfo.Id != #Admin     { selectfirstOnly RecId from  securityUserRole where securityUserRole.User  == userInfo.Id existsjoin securityRole where securityRole.RecId                     …