Skip to main content

Posts

Showing posts with the label strfmt

How to separate Fraction and Digit from Number in axapta

To separate Fraction and Digit from Number in axapta like number is 878778.3000 and you want to get 878778 and .300 then below code can help you to get the same. qty t=878778.3000; str _amount = strFmt("%1",num2str(t,0,1,0,0)); boolean decimals; TextBuffer txtAmount = new TextBuffer(); txtAmount.setText(_amount); if (txtAmount.find("^[0-9]+$")) // Regular expression inside the find method { decimals = true; } info(strFmt("%1 -- %2",trunc(t),frac(t)));

Code to get Employee Name For all employee in Ax 2012

 To get Employee Name For all employee in Ax 2012 You can get idea from below code. DirPerson dirPerson; HcmWorker hcmWorker; HRMDailyAttendance hrmDailyAttendence; ; while select Name ,gender from dirPerson join hcmWorker group by dirPerson.Name,dirPerson.Gender where hcmWorker.Person == dirPerson.RecId { info(strFmt("%1",dirPerson.Name)); }

How to find BOM Unit and Inventory Unit for item in Ax 2012

To find BOM Unit and Inventory Unit for item you can get idea from below code sample.This code you can try in your job code editor in axapta. InventTable inventTable; InventUnitId inventoryUnit,BOMUnit; BOM bom; ItemId curItem; ; while select BOM order by itemid where BOM.BOMQty { if(curItem != BOM.ItemId) { curItem = BOM.ItemId; inventTable = InventTable::find(bom.ItemId); inventoryUnit = inventTable.InventUnitId(); BOMUnit = bom.UnitId; if(!UnitOfMeasureConverter::canBeConverted(UnitOfMeasure::findBySymbol(inventoryUnit).RecId, UnitOfMeasure::findBySymbol(BOMUnit).RecId, inventTable.Product)) { if(inventoryUnit != BOMUnit) { info(strFmt("item %1 has bom unit %2, inventory unit %3",inventTable.itemId,BOMUnit,inventoryUnit)); } } }

split datetime in hour minutes second in different timezone in ax 2012

This is the example to  split datetime in hour minutes second in different timezone in ax 2012. TransDateTime myDateTime=DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::getSystemDateTime(),Timezone::GMTPLUS0300KUWAIT_RIYADH); int hours; int minutes; int seconds; ; info(datetime2str(myDateTime)); hours=DateTimeUtil::hour(myDateTime); minutes=DateTimeUtil::minute(myDateTime); seconds=DateTimeUtil::second(myDateTime); info(strfmt('Hours %1 - Minutes %2 - Seconds %3',int2str(hours),int2str(minutes),int2str(seconds))); To get different timezone like GMT,India etc you can get from below screen.

example of queryrun in MSD axapta

example of queryrun in axapta SysQueryRun queryRun = new SysQueryRun(querystr(MyQuery)); CustInvoiceJour custInvoiceJour; CustInvoiceTrans custInvoiceTrans; ; if (queryRun.prompt()) { while (queryRun.next()) { custInvoiceJour = queryRun.get(tableNum(CustInvoiceJour)); custInvoiceTrans = queryRun.get(tableNum(CustInvoiceTrans)); if (queryRun.changed(tableNum(CustInvoiceJour))) { info(strfmt("Account: %1", custInvoiceJour.invoiceAccount)); } if (queryRun.changed(tableNum(CustInvoiceTrans))) { info(strfmt("Item: %1, Qty: %2, ",custInvoiceTrans.itemId, custInvoiceTrans.qty)); } } }