Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Thursday, February 18, 2021

GUID in AX 2012 / D365

 //< What is GUID>

// GUID 16 bit large range of alphanumeric similar to RecID to treat as primary key of a table.

static void CreateGUIDInAX(Args _args)

    str 60 strGuid;

    ;

    info(Winapi::createGUID());         // Creates GUID and removes the braces

    info(guid2str(newGuid()));           // Creates GUID with braces

    //NOTE: GUID is not a string so we needs to convert GUID to str for using...

}

Output:

C2B4FEBF-2393-43BB-9EA5-B173B907CA2A

{BAD14349-5837-4AC3-9B9B-9D6FB0F86BEC}

note: Your output and mine needs to be same.


Regards.

Monday, January 11, 2021

Round the decimals (upper / lower) in AX 2012 / D365

 Hi,


static void AlfRound(Args _args)

{

    Amount  amount = 5578.59;

    info(strfmt("Amount %1", amount)); // Printing the original values

    info(strfmt("Round,1  - %1", round(amount,1))); // This performs standard operation of round and removes the decimal.

    info(strfmt("roundDown,1 - %1", roundDown(amount,1)));  //Always round by down with ones position, if you make 100 then output will be 5,500.00

    info(strfmt("roundDownDec,1 - %1", roundDownDec(amount,1))); // Down rounding only the decimal values

    info(strfmt("roundUpDec,1 - %1", roundUpDec(amount,1))); //Up rounding only the decimal values

    info(strfmt("roundup,1 - %1", roundup(amount,1))); //Always round by down with ones position, if you make 100 then output will be 5,600.00

    info(strfmt("roundUp(roundUp,1) - %1", roundUp(roundup(amount,1),1))); // Roud the rounded amount will not make any changes in the rounded amount.

    info(strfmt("decround,1 - %1", decround(amount,1))); // It performs the standard operation of round in decimal 

}


Regards,

Sunday, November 29, 2020

Minumum and Maximum date in AX 2012 / D365

 H,

// Minimum dateTime and Maximum DateTime

    utcdatetime                 minDateTime = DateTimeUtil::minValue();

    utcdatetime                 maxDateTime = DateTimeUtil::maxValue();


// Minimum date and Maximum Date

    TransDate                 minDate = dateNull();

    TransDate                 maxDate = dateMax();


Regards,

Monday, November 23, 2020

Convert Gregorian to Hijiri in D365

Hi,


The date value retuned by umAlQuraCalendar is not in the range of AX / 365 TransDate allowed. TransDate support from 1/1/1900 to 1/1/2155. You might be noticed Never as dateMax() value in AX tables, All those never is nothing but 1/1/2155.

Please find following script to convert Gregorian to Hijri with date separator "-".

I got an requirment to convert the date where Integrating system is not accepts 29-4-1442, API is looking for 29-04-1442

I added 0 before to the day and month if its less than 9.

Most of the functions available in umAlQura returns or accepts int32, please make sure you convert before you proceed with.

NOTE: Please dont try to covert the string what hijri returns to transDate, that results in error.

public static str 30 Gregorian2Hijri(TransDate _transDate)

{

    System.Globalization.UmAlQuraCalendar umAlQuraCalendar = new System.Globalization.UmAlQuraCalendar();

    System.Globalization.GregorianCalendar gregorianCalendar = new System.Globalization.GregorianCalendar();

    str yearStr, monthStr, dayOfMonthStr;

    ;

    yearStr = umAlQuraCalendar.GetYear(_transDate);

    monthStr = umAlQuraCalendar.GetMonth(_transDate);

    dayOfMonthStr = umAlQuraCalendar.GetDayOfMonth(_transDate);

    if(strLen(monthStr) == 1)

        monthStr = "0"+monthStr;

    if(strLen(dayOfMonthStr) == 1)

        dayOfMonthStr = "0"+dayOfMonthStr;

    return strFmt("%1-%2-%3",dayOfMonthStr,monthStr,yearStr);

}

Regards,

Saturday, November 14, 2020

Why DirPerson table is not exists in SQL

Hi,


Why DirPerson table is not exists in SQL?


The DirPerson table has the property SupportInHeritance with YES and Extends with DirPartyTable.


SQL Table architecture doesnt support inheritance.


There are few more tables in AX with such property example OMOperatingUnit.


Regards,

Sunday, November 8, 2020

Marshaling Webservices enum to X++ during integration

 Hi,


    NICServiceLibrary.EltezamServiceRef.GenderType           M,F,N;

    M = NICServiceLibrary.EltezamServiceRef.GenderType::M;

    F = NICServiceLibrary.EltezamServiceRef.GenderType::F;

    N = NICServiceLibrary.EltezamServiceRef.GenderType::N;

;

        PersonalInfoStructure.set_Gender(M);


Regards,


Get a table ID in SQL / table browser - D365

Hi select ID from SysTableIdView where  SysTableIdView .Name = 'CustTable' <URL>/?cmp=<CompanyID>&mi=sysTableBrowser...