Showing posts from December, 2009

Temporary tables in forms

Using temporary tables in forms requires the use of the .setTmpData() method. For example: The temporary table data is populated in a static class method (running server side), which is called from the form and returns the populated table. We could populate a form-level buffer with the temporary data if needed, or else just call the populating method directly from the setTmpData() call as shown below. In the form datasource init(), we use .setTmpData() to instruct the datasource query to use our temporary table. Our datasource name in this example is TempTable. public void init() { super(); TempTable.setTmpData(tmpTableClass::populateTmpData()); }

Send email by using SysMailer

There are several methods to send email in Axapta. Using SysMailer is one of those. Method 1 (Normal): static void Email1(Args _args) { SysMailer mailer = new SysMailer(); ; mailer.quickSend("","","subject","body"); } Method 2 (Simple): static void Email2(Args _args) { SysMailer mailer = new SysMailer(); SysEmailParameters parameters = SysEmailParameters::find(); ; if (parameters.SMTPRelayServerName) { mailer.SMTPRelayServer(parameters.SMTPRelayServerName, parameters.SMTPPortNumber, parameters.SMTPUserName, SysEmailParameters::password(), parameters.NTLM); } mailer.fromAddress(""); mailer.tos().appendAddress(""); mailer.htmlBody("hi"); mailer.sendMail(); }

Post packing slip of sales order in X++

SalesFormletter SalesFormletter; SalesTable SalesTable; ; SalesFormletter = SalesFormletter::construct(DocumentStatus::Confirmation,true); SalesTable.clear(); SalesTable = SalesTable::find(_salesId); SalesFormletter.update(SalesTable, systemDateGet(), SalesUpdate::All, AccountOrder::None, false, false);

GetSystemDateTime() difference

Situation: I tried to update a datetime value of a external database to let say GetSystemDateTime(). However, it was found that the time updated was not equal to GetSystemDateTime(). Solution: It is because of time zone problem. In AX 2009, datetime is stored in UtcDateTime format. During presentation, the offset timezone of the user option is calculated. So you can make use of the following code to update datetime DateTimeUtil::applyTimeZoneOffset(datetimeutil::getSystemDateTime(), DateTimeUtil::getUserPreferredTimeZone());

How to post purchase order packing slip with WMSJournalId

I was requested to post the packing slip of purchase order automatically after post the item arrival. Below is the main code to post packing slip with WMSJournal void SIT_Post_PurchFormLetter_PackingSlip(WMSJournalTable _WMSJournalTable) { PurchFormLetter_PackingSlip purchFormLetter_PackingSlip = PurchFormLetter::construct(DocumentStatus::PackingSlip); ; purchFormLetter_PackingSlip.SIT_ParmWMSJournalId(_WMSJournalTable.journalId); purchFormLetter_PackingSlip.transDate(today()); purchFormLetter_PackingSlip.update(_WMSJournalTable, _WMSJournalTable.JournalId, today(), PurchUpdate::Recorded); }

How to reverse packing slip of Purchase Order or Sales Order

It can be done by use "Delivery now" or "Receive now" in the quantity tab of sales order and purchase order form.

Google Chrome Extensions

Google Chrome extensions officially launched. (but still in beta) You can find extensions in the following website:

How to Delete All Transaction and Keep Master Setup

You can run class  SysDatabaseTransDelete to delete all transactions.