Skip to main content

Posts

Showing posts from January, 2012

Show/Hide the dialog range field

To hide/show the query dialog field, you need to implement/override the showIndexFields() method of the dialog and return FALSE if you want to hide the field from the dialog query range. here is an example: public boolean showIndexFields(tableId _tableId) { boolean ret = true; switch (_tableId) { case tableNum(YourTable): ret = false; break; } return ret; }

Dynamics AX 2009 and Dynamics AX 2012 modules comparisons

Following are the enhancements made by Microsoft on Dynamics AX 2012: For example, GL module in AX 2009 is now break into GL and Fixed assets in AX 2012. AX 2009 Module AX 2012 Module General Ledger General Ledger Fixed Assets (New) Bank Cash and bank management Accounts Payable Accounts Payable Procurement and sourcing (New) Accounts Receivables Accounts Receivables Sales and Marketing (New) Inventory Management Product information (New) Inventory and warehouse management Expense management Travel and expense management Production Production control Project Project management and accounting Compliance and internal control (New)

Set focus on specific control when opening form

To set the focus on specific control when form is open, you need to override the firstField() method of the form and set your desired control after super() call. public void firstField(int _flags=1) { ; super(_flags); desiredControlName.setFocus(); }

Modify InvoiceDate, TransDate .. on already posted Vendor Invoice

you have to try first run test system . static void xxx(Args _args) { invoiceId NumFacturaDesde; invoiceId NumFacturaHasta; CustInvoiceJour _custinvoicejour; CustInvoiceSalesLink _custinvoicesaleslink; CustInvoiceTrans _custinvoicetrans; LedgerTrans _ledgertrans; CustTrans _custtrans; CustTransOpen _custtransopen; InventTrans _inventtrans; TaxTrans _taxtrans; CustBillOfExchangeInvoice _CustBillOfExchangeInvoice; CustBillOfExchangeTrans _CustBillOfExchangeTrans; CustSetTlement _CustSetTlement; InvoiceDate FechaBuena; ; //Inicializamos variables NumFacturaDesde = '035884'; NumFacturaHasta = '035884'; FechaBuena = str2date("22.04.2005",123); ttsbegin; _custinvoicejour.clear(); SELECT FORUPDATE * FROM _custinvoicejour WHERE _custinvoicejour.InvoiceId>=NumFacturaDesde && _c

Finding unused labels in Dynamics Ax 2009

static void FindUnUsedLabels() { str 50 labelId; str labelString; int i; //set max label to the highest number of labelId in your application int maxLabel = 2000; xRefNames names; XRefReferences ref ; ; while (i <= maxLabel) { //Sequential generation labelId = "@IFC" + int2str(i); //Find if the label id has an cross reference //record select recid from names where names.Name == labelid exists join ref where names.RecId == ref .xRefNameRecId; labelString = SysLabel::labelId2String(labelId); //If there is no record in cross reference then log it if (! names.RecId && //avoid logging labels that are already deleted (This is because of sequential check like IFC1, IFC2, IFC3 etc...)

Quick Excel report – Dynamics Ax 2009

Excel is the most convenient software to examine changes in data. Specially when you have made them code and wanted it to be tracked. That’s is one of the many reasons why excel tops to be the most used software in the world. This article in detail will tell you how to create an ad hoc excel sheet just in case you wanted to show data changes, compile information from different tables etc. static void JobExportToExcel(Args _args) { SalesLine salesLine, oldSalesLine; str text; TextIO io; #WinAPI ; //Column header for the excel. The header fields and the data field must match //in number and order //You can use anything as a delimiter but # is convenient as this rarely appears //as data (other choices ~, |) text = 'Order # Customer # Item # Lot id # New tax group # Old tax group \n' ; select * from salesLine where salesLine.TaxItemGroup == 'GST' ||

Posting Invoice from Sales order/ Purchase order

static void postSalesInvoice(Args _args) { // Define a classvariable according to the // type of posting being performed SalesFormLetter_Invoice invoice; SalesTable salesTable; ; // Select the salesTable to update salesTable = SalesTable::find(“SO-101297″); // Create a new object of the SalesFormLetter_Invoice // by using the construct-method in SalesFormLetter invoice = SalesFormLetter::construct(DocumentStatus::Invoice); // Post the invoice invoice.update(salesTable, SystemDateGet(), SalesUpdate::All, AccountOrder::None, false, true); // Set to true to print the invoice } The next screenshot shows the class hierarchy of FormLetter with all its subclasses: we can easily custamize the above logic to post different status updates against sales orders and purchase orders Sales (Confirmation, Picking list, Packing slip, Invoice ) Purch (Purchase order,Receipt list, Packing slip, Invoice)

How to print sales Invoice ?

public void printInvoiceReport(PurchId _purchId) {     ReportRun report;     RecordSortedList List = new RecordSortedList(tableNum(VendInvoiceJour));     VendInvoiceJour VendInvoiceJour = VendInvoiceJour::findFromPurchId(_purchId);     PurchFormLetter PurchFormLetter;     ;     if (VendInvoiceJour.RecId)     {         report = new ReportRun( new Args(ReportStr(PurchInvoice)));         List.ins(VendInvoiceJour);         report.args(). object (List);         report.query().interactive( false );         report.report().interactive( false );         report.args().parmEnum(0);         report.args().parmEnumType(920);         report.args().name( "KeepSettings" );         report.args().caller(PurchFormLetter);         report.setTarget(PrintMedium::Screen);         report.printJobSettings().setTarget(PrintMedium::Screen);         report.printJobSettings().preferredTarget(PrintMedium::Screen);         PurchFormLetter     =   PurchFormLetter::construct(

How to print Performa Sales Invoice?

static void Test_SalesFormLetter(Args _args) {     SalesFormLetter letter=SalesFormLetter::construct(DocumentStatus::Invoice);     SalesTable sale = SalesTable::find( 'ORDR00000229' ); ;     ttsBegin;     letter.update(sale, systemDateGet(), SalesUpdate::PickingList, AccountOrder::None, true , true );     ttsCommit; }

How to create return Order from code

static void SR_CreateReturnOrderAfterInvoice(Args _args) { CustInvoiceJour _invoiceRec; str _returnReason; CustInvoiceTrans custInvoiceTrans; SalesLine salesLine; SalesTable newRetOrder; CustInvoiceJour custInvoiceJour; SalesTable createReturnOrderHeader(CustInvoiceJour invoiceRec) { SalesTable old, newRec; boolean bChecksOk = true ; ; old = SalesTable::find(invoiceRec.SalesId); newRec.initReturnFromSalesTable(old); newRec.CustAccount = old.CustAccount; newRec.initFromCustTable(); newRec.CustInvoiceId = invoiceRec.InvoiceId; newRec.ReturnDeadline = today(); newRec.ReturnReasonCodeId = ’21′; // Defective newRec.SalesType = SalesType::ReturnItem; newRec.SalesTaker = SysCompanyUserInfo::current().EmplId; if ( newRec.ReturnReasonCodeId == ” && CustParameters::find().ReturnOrdersReasonReq || newRec.ReturnReasonCodeId != ” && !ReturnReasonCode::exist(newRec.ReturnReasonCodeId) ) { checkFailed(strfmt(“@SYS26332″, fieldid2pname(tablenum(SalesTa

How to create SALE ORDER from code in dynamics ax

static void createSalesTable(CustAccount _custAccount) { SalesTable salesTable; NumberSeq NumberSeq; ; NumberSeq = NumberSeq::newGetNumFromCode(SalesParameters::numRefSalesId().numberSequence); salesTable.SalesId = NumberSeq.num(); salesTable.initValue(); salesTable.CustAccount = _custAccount; salesTable.initFromCustTable(); salesTable.insert(); } static void createSalesLine(SalesId _salesId, ItemId _itemId) { SalesLine salesLine; ; salesLine.clear(); salesLine.SalesId = _salesId; salesLine.ItemId = _itemId; salesLine.createLine(NoYes::Yes, // Validate NoYes::Yes, // initFromSalesTable NoYes::Yes, // initFromInventTable NoYes::Yes, // calcInventQty NoYes::Yes, // searchMarkup NoYes::Yes); // searchPrice }

How can I disable the automatic sort on the grid?

I'm using AX 2009. My form data source is a view. I use filtering and data group with a separate Query connected from code to the data source. My main problem is that if I use header sort in the grid the result will be a single record with the sum of a field (the Query has a sum field - I assume because of this...). I want to disable the auto sort on this grid, but I don't have a clue how. I am afraid that my query won't work if I can disable it. Has anyone experience with this? I've ran into this problem before (also using a view with group by on a grid), and I was able to get the header sort working properly without condensing the entire contents down to one record by changing my query code around a little bit: On the queryBuildDataSource, I called orderMode(OrderMode::GroupBy) I also used selection fields instead of group by commands: queryBuildDataSource.addSelectionField(fieldnum(myTable, myField), SelectionField::Sum) I haven't quite naile

Dynamics Ax 2009 Financials : Year-End process

Please find the Year-end closing process below: Step 1: Create a new fiscal year Path: Dynamics Ax > General Ledger > Setup > Periods > Periods Click button 'Create new fiscal year' Click 'OK' 12 monthly lines get created with open status. Step 2: Control transactions in a closing period Path: Dynamics Ax > General Ledger > Setup > Periods > Periods A closed period cannot be reopened. Therefore, permission to close periods and years should be highly restricted. Select 'Stop' from list and this prevents transactions posting in the system for that period, perfom same operation for 12 monthly periods. Step 3: Change module status Select the appropriate module and set the user group required access by selecting from list view in the above screen. Step 4: Create Closing sheet Path: Dynamics Ax > General Ledger > Periodic > Fiscal year close > Closing sheet Set field 'Closing sheet' = 06/30/2011

AX 2009 - How to Transfer Security Settings to a Production Server

Translate this page Arabic Bulgarian Catalan Chinese Simplified Chinese Traditional Czech Danish Dutch Estonian Finnish French German Greek Haitian Creole Hebrew Hindi Hungarian Indonesian Italian Japanese Korean Latvian Lithuanian Norwegian Polish Portuguese Romanian Russian Slovak Slovenian Spanish Swedish Thai Turkish Ukrainian Vietnamese Microsoft ® Translator Check out this page in {0} translated from {1} translated from Original: Translated: Automatic translation powered by Microsoft® Translator Start translating Stop translating Close Close and show original page Select Summary: If you are in a situation where you have created your AX security settings on another AX instance and you now need to move them to your production server, below are a few options for how to accomplish this. Assumptions: This is a one-time transfer from the STAGING server to the PRODUCTION server The security settings transferred from the STAGING server will be the final settings on the PRODUCTIO

BREAKPOINT command in X++

Hi! I'm back on track and the first thing I want to share after my vacation is a rather undocumented X++ statement: BREAKPOINT In any X++ line, you can write BREAKPOINT; which will trigger a breakpoint on this line and open the debugger. With that, you could circumvent the fact that Axapta does not know conditional breakpoints and you could write a line like that: if (i>10) BREAKPOINT;

Activating query tracing for all users

Sometimes when you are tracking performance (or other) problems, you may want to activate the long running query tracing for all users. Here is a little job that will do that. Beware: you have to activate trace settings on your AOS server, unless most of the queries will not be caught. static void Set_SQLTrace_AllUsers(Args _args) { #LOCALMACRO.FLAG_SQLTrace (1 << 8) #ENDMACRO #LOCALMACRO.FLAG_TraceInfoQueryTable (1 << 11) #ENDMACRO boolean set; UserInfo userInfo; ; set = true; ttsbegin; while select forupdate userinfo { userinfo.querytimeLimit = 1000; if (set) { userInfo.DebugInfo = userInfo.DebugInfo | #FLAG_SQLTrace; userInfo.TraceInfo = userInfo.TraceInfo | #FLAG_TraceInfoQueryTable; } else { userInfo.DebugInfo = userInfo.DebugInfo ^ #FLAG_SQLTrace; userInfo.TraceInfo = userInfo.TraceInfo ^ #FLAG_T

Automatically open grid filter when opening form

In some forms it may be convenient that the grid filter (new in Ax 4.0) is activated automatically. If you want to get that behaviour, just add one line in the form's run method, just after the super() call: this.task(2855); So, your run() method should look like: public void run() { ..... // some programming lines.... super(); this.task(2855); }

Send message to online user in Dynamics AX 4.0 (quick & dirty)

I am missing the functionality to send messages to online users that existed in Axapta 3.0 and is now gone. Well, I thought you could use the "Alert" functionality introduced in DAX 4.0. What to do: 1. make sure the user options are configured correctly (that means: set "Time poll interval" to 1 minute, set "Show popup" to "For all event rules") 2. make a button in the online user form that will open a dialog where you could enter your text 3. send the message to all users selected in the online user form datasource Here is a little job that creates an alert for a user. Remember this is a quick & dirty solution, so there are some drawbacks: * you will get an error in the alert form on the second tab * the message will only be displayed about 15 sec and disappears afterwards (you can check FRM EventAttentionGrabber to change that. Check methods fadeIn and fadeOut for variable opacity. This should give you a hint on how to