Posts

Showing posts with the label Axapta

Send message or alert to all online users

In Axapta 2.5 or 3.0, there is a standard function to send message to all online users. But it has been taken away after AX 4.0. However you still do this by some codes: static void sendAlertToOnlineUsers(Args _args) { EventInbox inbox; EventInboxId inboxId; SysClientSessions sessions; ; while select sessions where sessions.Status == SessionState::Running { inboxId = EventInbox::nextEventId(); inbox.initValue(); inbox.ShowPopup = NoYes::Yes; inbox.Subject = "GIT TESTING ALERT MESSAGE"; inbox.Message = "HELLO?"; inbox.SendEmail = false; inbox.UserId = sessions.userId; inbox.InboxId = inboxId; inbox.AlertCreatedDateTime = DateTimeUtil::getSystemDateTime(); inbox.insert(); } }

What images are available for the NormalResource Property

It is under: Microsoft Dynamics AX menu > Tools > Development tools > Embedded resources. The window displays the available images, and the Resource ID of each image.

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("mike@abc.com","mike@abc.com","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("mike@abc.com"); mailer.tos().appendAddress("mike@abc.com"); 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. http://daxfaq.studioerudit.com/#post3

How to Delete All Transaction and Keep Master Setup

You can run class  SysDatabaseTransDelete to delete all transactions.

Table Synchronize Error

During the customization of AX 2009, I always get this error prompt out when modifing table, index, EDI or even compile the whole AOT: Cannot execute a data definition language command on ().The SQL database has issued an error. It told neither what table nor index have error. Finally I found a job which can tell you what table cause the synchronization error. static void SIT_ForceDbSynchronize(Args _args) { Dictionary dict; int idx, lastIdx, totalTables; TableId tableId; Application application; SysOperationProgress progress; StackBase errorStack; ErrorTxt errorTxt; ; application = new Application(); dict = new Dictionary(); totalTables = dict.tableCnt(); progress = new SysOperationProgress(); progress.setTotal(totalTables); progress.setCaption("@SYS90206"); errorStack = new StackBase(Types::String); lastIdx = 0; ...

AX 2009 enum DateFlags error

Situation: When you compile the AOT, you got a error which said enum DateFlags not found. Solution: Probably the problem was in different version of client and AOS. Client was AX 2009 without SP1. After installation of service pack on client machine. The compilation was OK.

Add a new inventory dimension

Dynamics AX 2009 includes the following inventory storage dimensions from the packaging: Warehouse Batch number Location Pallet ID Serial and item dimensions: Configuration Color Size Sometimes it may not be enough for the business needs. To add a new dimension, you can follow the steps below: First, I assume you have create the dimension tables (similar to InventColor, InventBatch) Add the key field into the table InventDim. Then add to the field group InventDimensions and InventoryDimensions Add fields to the DimIdx as well as relations if necessary. And then modify some methods if InventDim, just goes thru all methods. Add fields to InventDimParm also. Modify macro InventDimJoin and InventDimSelect. The most important things is do a seach at the top of AOT with #InventDimDevelop as the keywords. Do a complete Recompilation of all stuffs. Finish! You are suggested to add all new dimensions before the system implementation. If there's some open transaction, we...