Sunday, August 11, 2013

Lookup on PersonnelNumber and Name in Ax2012

In Ax2009 EmplTable now replaced with hcmWorker Table. To get emplid and emplname below is the lookup code:
public void lookup()
{
    HcmWorker               hcmWorker;
    SysTableLookup          sysTableLookup = SysTableLookup::newParameters(hcmWorker.TableId, this);
    Query                   query = new Query();
    QueryBuildDataSource    queryBuildDataSource = query.addDataSource(hcmWorker.TableId);

    queryBuildDataSource.addSortField(fieldNum(HcmWorker, PersonnelNumber));

    sysTableLookup.addLookupfield(fieldNum(HcmWorker, PersonnelNumber));
    sysTableLookup.addLookupfield(fieldNum(HcmWorker, Person));

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

Happy - Daxing :)-

Monday, August 5, 2013

AX 2012: Enabling Allow Check Reuse for Canadian Environments & India also....!!

Per TechNet article (CAN, USA) Reuse a check number [AX 2012] environments that are on AX 2012 with the Feature Pack have the ability to enable the Allow Check Reuse feature in Cash and Bank Management Parameter for US and Canadian Companies. I wanted to provide information that will allow you to enable the Allow Check Reuse feature for Canadian Companies if you have updated to AX 2012 Feature Pack and do not see the option to enable Allow Check Reuse in Cash and Bank Management Parameters for your Canadian company.
In order to enable the Allow Check Reuse for Canadian Companies the CountryRegionCodes that are part of the BankParameters table may need to be updated via the AOT. Please note that this is not a documented/tested HotFix so making the below changes will be at you own risk and testing should be done in a Sandbox environment prior to applying to a production environment.

  1. Open the AOT (Ctrl+D).
  2. Expand Data Dictionary
  3. Expand Tables.
  4. Locate the BankParameters table.
  5. Expand the BankParameters table.
  6. Expand Fields.
  7. Click on AllowCheckReuse
  8. In the Properties pane locate CountryRegionCodes (US should be listed by default)
  9. Add IN to the CountryRegionCodes along with US,CA (US, CA,IN).
  10. Compile to bring the changes into the environment.
Below is a screenshot showing the properties window where the changes need to be made.
Already there are US,CA pls add IN (India) also.
Daxing :)

Thursday, August 1, 2013

fetch data and time from UTCDateTime control in Ax2012

public static void testDateTimeConversion()
{
    utcDateTime               dateTime;
    date                             dateInUserTimeZone;
    TimeOfDay                 timeInUserTimeZone;


    dateTime = DateTimeUtil::utcNow();

   dateInUserTimeZone = DateTimeUtil::date(DateTimeUtil::applyTimeZoneOffset(dateTime,  DateTimeUtil::getUserPreferredTimeZone()));

    timeInUserTimeZone = DateTimeUtil::time(DateTimeUtil::applyTimeZoneOffset(dateTime, DateTimeUtil::getUserPreferredTimeZone()));

    dateTime = DateTimeUtil::newDateTime(dateInUserTimeZone, timeInUserTimeZone, DateTimeUtil::getUserPreferredTimeZone());
}


Happy Daxing :)

Convert Number to string in Ax 2012

Examples
Num2Str(12345.6,10,2,2,1)
returns "12.345,60".
Num2Str(12345.6,1,0,1,0)
returns "12346".

Convert Between utcdatetime and System.DateTime in AX 2012

static void JobDateTimeGlobalMarshal(Args _args)
{
    System.DateTime netDttm;
    utcdatetime xppDttm;
    str xppString;
    ;
    xppDttm = 2007-06-05T23:22:21; // ISO standard format.
   
    // Convert X++ to .NET.
    netDttm = Global::utcDateTime2SystemDateTime(xppDttm);
   
    // Convert .NET to X++.
    xppDttm = Global::CLRSystemDateTime2UtcDateTime(netDttm);
   
    xppString = DateTimeUtil::toStr(xppDttm);
    info("xppDttm: " + xppString);
}