Posts

Showing posts from June, 2014

Local Macro's in AX

Today I will demonstrate you that how to create Local Macro's and use them in AX. Local Macro’s  static void Local_Macro(Args _args) { // Define the local macro #localmacro.WelcomeMessage { info("Welcome to Carz Inc."); info("We have the best offers for rental cars"); } #endmacro; // Use the local macro #WelcomeMessage }

Insert_RecordSet Class in AX

Today I will demonstrate you that how to use Insert_RecordSet Class in AX. Insert_Recordset() Method static void Insert_Recordset(Args _args) { CarTable carTable; CarTable carTableTmp; ; carTableTmp.setTmp(); carTableTmp.CarId = "200"; carTableTmp.CarBrand = "MG"; carTableTmp.insert(); carTableTmp.CarId = "300"; carTableTmp.CarBrand = "SAAB"; carTableTmp.insert(); carTableTmp.CarId = "400"; carTableTmp.CarBrand = "Ferrari"; carTableTmp.insert(); Insert_Recordset carTable (carId, carBrand) select carId, carBrand from carTableTmp; }

Exception Handling in AX

Today I will demonstrate you that how to use Try, Catch, Throw and Retry keyword in AX. Try-Catch-Retry-Throw static void ExceptionHandling(Args _args) { try { info("Now I’m here"); if (true)    throw error("Oops! Something happened"); info("Now I’m there"); } catch (Exception::Error) { info ("I would like to inform you that an error occured "); } catch (Exception::Deadlock) { sleep(10000); retry; } info ("This is the end"); }

SubStr Method in AX

Today I will demonstrate you that how to use SubStr() method in AX 2012. Substr() Method static void Datatypes_string_substr(Args _args) { str carBrand; ; carBrand = "Volkswagen"; print substr(carBrand, 6, 5); //Substr(string value /string variable name,starting postiont, number of elements);  pause; }

Type Conversion Methods in AX 2012

Today I will demonstrate you that how to use type conversion methods in AX 2012. Enum2int() Method static void Datatypes_enum2int(Args _args) { SalesType salesType; salesType = SalesType::Sales; info(strfmt("The value of the current sales-type element is %1",enum2int(salesType))); } Enum2Str() Method static void Datatypes_enum2str(Args _args) { SalesType salesType; salesType = SalesType::Sales; info(strfmt("The name of the current sales-type is '%1'", enum2str(salesType))); } Num2Str() Method static void Datatypes_Num2str(Args _args) { str mileage; real mileageNum; mileageNum = 388272.23; /* num2str(number to be converted, minimum characters required, required number of decimals, decimal separator <1=point, 2=comma>, thousand separator <0=none, 1=point, 2=comma, 3=space>) */ mileage = num2str(mileageNum,0,2,2,0); print strfmt("The car has run %1 miles", mileage); pause; } Str2Num() Method static v

Anytype Data Type in AX 2012

Today I will demonstrate you that how to use AnyType Data Type in AX 2012. static void Datatypes_anytype(Args _args) { anytype any; any = "ABC"; print any; any = 55; print any; any = systemdateget(); print any; pause; }