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);
}

Tuesday, July 30, 2013

Binding for buffer allocation space - error in Ax2009

While defining record level security for the user group's if there are too many queries instead of specifying based on customer group if user's define based on customer id etc.. and too many wild characters like (*). then client machine performance will be very slow and system may hangsup and some times u get an errror like "binding for buffer allocation space".

Thanks,
Daxing :)

Lookup on breakdown structure defined on a perticular projectid:

For a perticular projectid there can be any number of work breakdown structure defined based on activityid. If you develop a new table and form and get that plan names besed on selected project then : Here NewPaymentPlanTable is the new table.

Below code is on form control - lookup method:

public void lookup()
{
HierarchyTreeTable                  hierarchyTreeTable,hierarchyTreeTable1;
ProjTable                                  projTable1;
Query                                       query = new Query();
SysTableLookup                      sysTableLookup;
projTable1 = ProjTable::find(NewPaymentPlanTable_ProjId.text());
super();
select firstonly Name,ElementNumber from HierarchyTreeTable where HierarchyTreeTable.Name == projTable1.ProjId;
select firstOnly ElementNumber from hierarchyTreeTable1 where hierarchyTreeTable1.ParentElementNumber == hierarchyTreeTable.ElementNumber;
sysTableLookup = SysTableLookup::newParameters(tableNum(hierarchyTreeTable), this);
// Add name field to be shown in the lookup form.
sysTableLookup.addLookupfield(fieldNum(HierarchyTreeTable, SiblingNumber));
sysTableLookup.addLookupfield(fieldNum(HierarchyTreeTable, Name));
sysTableLookup.addLookupfield(fieldNum(HierarchyTreeTable, ElementNumber));
sysTableLookup.addLookupfield(fieldNum(HierarchyTreeTable, ElementNodeType));
query = new Query();
query.addDataSource(tableNum(HierarchyTreeTable)).addRange(fieldNum(HierarchyTreeTable, ParentElementNumber)).value(queryValue(hierarchyTreeTable.ElementNumber));
sysTableLookup.parmQuery(query);
// Perform the lookup.
sysTableLookup.performFormLookup();
}