Skip to main content

Posts

Showing posts from December, 2011

Edit metod in axapta

Requirement : : We need to write the edit method on the places where we need to select the records and pass it to the business logic for further processing. Also, we need edit methods to display the values of the related record from other table when the related table is not a part of the form datasource. The same purpose can be handled using display method as well but edit method allows us to modify the values in the display method. So, we can say that: Edit Method = Display Method + Editing capability How to write an Edit Method : We can write an edit method using the code shown below. Before getting in to the code, we must understand the requirement of the below code: · We have a form which is listing the Project Invoices in a grid · We need to have a checkbox next to all the records to select/deselect the records · We want to keep the Record Ids of the selected records in to a container so that we can use it for processing. · ...

Phone Number Formatting Mask

The following methods were added/changed: ClassDeclaration of Customers form public class FormRun extends ObjectRun { ... boolean sisValidateCalled; } StringEdit Phone field methods: public void enter() { super(); sisValidateCalled = false ; } public boolean validate() { #define.CorrectPhoneLettersNumber(14) boolean ret; int length; Phone newPhone; ; ret = super(); // creates new phone number in the format (xxx) xxx-xxxx[x] newPhone = SISTools::formatPhoneNumber( this .text()); length = strlen(newPhone); if (length != #CorrectPhoneLettersNumber) checkFailed(strfmt( "Phone numbers should be like: (xxx) xxx-xxxx" )); CustTable.Phone = newPhone; CustTable_ds.write(); sisValidateCalled = true ; return ret; } public boolean leave() { boolean ret; ret = super(); if (!sisValidateCalled) this .validate(); return ret; } SISTools class (some collection of utilities) ...

Adding Barcode to a Report

First, create a method like the following either on your Report element or in the relevant Section. display str 30 barcodeRefNum() { Barcode barcode; ; barcode = Barcode::construct(BarcodeType::Code128); barcode.string(true, custPackingSlipJour.packingSlipId); return barcode.barcodeStr(); } Note the BarcodeType enumeration that provide you with options other than 128. Then, add a String control to your report and use your new method as the data method. You could also have attached the display method directly to the underlying table if that's better for you. Finally, set the width, height, and alignment, and finally the font to your required symbology, i.e. "BC C128 Wide". Code 39, 128, UPC, and several others come with the Dynamics AX client. Add 'barcode.encode()' line before return statement.

How to write code to create Item counting journal line in AX 2009

My task is created an item counting journal line through X++ code InventDim inventDim; InventJournalTrans journalTrans; TmpImportInventJournal tableBuffer; InventJournalTable inventJournal; real lineNum = 1; TmpImportInventJournal tmpTable; // tmpTable here is used to stored item counting data InventJournalName inventJournalName; NumberSeq numberSeq; ; ttsbegin; select forupdate * from inventJournal where inventJournal.JournalId == inventJournalId; select firstonly inventJournalName where inventJournalName.JournalNameId == InventParameters::find().CountJournalNameId; numberSeq = NumberSeq::newGetVoucherFromCode(inventJournalName.VoucherSeqId); while select * from tmpTable { inventDim.clear(); journalTrans.clear(); inventDim.initValue(); inventDim.configId = tmpTable.configId; inventDim.inventBatchId = tmpTable.inventBatchId; inventDim.InventLocationId = tmpTa...

Multiple Grid Selections 2

1. Yeni bir form yapın. (Ör : ATOL_CustTableSelection) 2. Formunuzun dataSource düğümüne formda göstermek istediğiniz tabloyu sürükleyip bırakın. (Ör CustTable) 3. Formunuzun metodlarını alttaki gibi düzenleyin. 1 //classDeclaration metodunu değiştirin 2 3 public class FormRun extends ObjectRun 4 { 5 Map markedLines; 6 } 1 //init metodunu değiştirin 2 3 public void init() 4 { 5 super(); 6 7 this .initMarkedLines(); 8 } view source print ? 1 //yeni bir metod ekleyin 2 void initMarkedLines() 3 { 4 ; 5 markedLines = new Map(Types::Int64, Types::String); 6 } view source print ? 01 //yeni bir metod ekleyin 02 void showSelected() 03 04 { 05 MapEnumerator mapEnumerator; 06 RecID recId; 07 int lineNum = 1; 08 CustTable custTableLocal; 09 ; 10 mapEnumerator = markedLines.getEnumerator(); 11 12 while (mapEnumerator.moveNext()) 13 { 14 recId = mapEnumerator.curr...

Multiple grid selections

you can add a method on  buton clicked void clicked() {   CustTable custTableLocal;   FormDataSource custTableDs;   ;   super();   custTableDs = custTable.dataSource();   for (custTableLocal = custTableDs.getFirst( true ) ?     custTableDs.getFirst( true ) :     custTableDs.cursor();     custTableLocal;     custTableLocal = custTableDs.getnext())   {     info(strFmt( "%1 %2" , custTableLocal.AccountNum, custTableLocal.Name));   } } you can use this  form ve rapors with args.Record()

Smarter dialogs

I don’t know about you, but it seems to me that dialogs for jobs in AX gets more and more complicated. I have a feeling a few of them could solve most of the world’s problems with hunger and pollution, if I could only figure out how fill the dialog fields correctly… Users need help and guidance with the dialogs and to give the best guidance you may need to react to the choices made by the user in the dialog. Two methods on RunBase allow you to hook up some events from the dialog form with your RunBase inheriting class: dialogSelectCtrl is executed every time a new control is selected. I.e. when you move from one field to another. dialogTask is executed every time the task method of the dialog form is called. Here’s an example of how you can enable or disable fields based on what the users selects. class dialogTest extends RunBase { DialogField dialogFieldCustVend; DialogField dialogFieldCustAccount; DialogField dialogFieldVendAccount; } public container p...

How to use "Like" operator in the QueryBuildRange.Value

To make something as the "LIKE" operator in a query, you should just assign a value to the queryRange including a wildcard. The query framework will then change the statement into a LIKE statement. If the value does not contain a wildchard the query framework will change the statement to ==. Example: static void QueryBuildRange_Like(Args _args) { Query query = new Query(); QueryRun queryRun; QueryBuildDataSource queryDataSource; QueryBuildRange queryRange; CustTable custTable; ; queryDataSource = query.addDataSource(tablenum(CustTable)); queryRange = queryDataSource.addRange(fieldnum(CustTable, Name)); queryRange.value('The*'); queryRun = new QueryRun(query); while (queryRun.next()) { custTable = queryRun.get(tablenum(CustTable)); info (custTable.Name); } }

Parm metod ile nesneler arasında parametre göndermek

Merhaba Ax’ta iki nesne arasında iletişimi args sınıfıyla sağladığımızdan bahsetmiştik. Bu makelede Args().Celler() metodunun bir kullanımını anlatacağım. Şöyel bir istek olsun: Bir formum var içerisinde ItemId ve TransDate seçebildiğim iki alanım var. Bu alanlar herhangi bir tablodan gelmiyor. Direk form üzerinde oluştrulmuş alanlar. Ben bu iki alanı doldurduktan sonra bir butonla başka bir form açtırıyorum ve bu iki alanın değerini açtırdığım forma göndermek istiyorum. Alan isimlerimiz ItemIdField ve TransDateField olsun. Bunlar için birinci forma parm metodlar yazalım. 1 2 3 4 5 6 7 8 9 10 ItemId parmItemId() { ; return ItemIdField.valueStr(); } TransDate parmTransDate() { ; return TransDateField.valueStr(); } Buton ile açtırdığım ikinci formun init metoduna şöyle bir kod yazarsam bu iki değeri almış olurum. 1 2 3 4 5 6 7 8 9 10 public void init() { ItemId itemId; TransDate transDate; ; itemId = element....

Update Query Range at Runtime in Dynamics AX

In Dynamics AX we can update the Query Range at run-time in code, This is similar to "Filter by Grid" feature except that we are handling this in code. For example my user asked me to provide a Button on Sales LineItems which would toggle between displaying "Current SalesLineItems" VS "All SalesLineItems". By Current SalesLineItems i mean displaying LineItems with more than zero quantity, other addendum to original requirement is to preserve the existing user filters on the form. In this image you can see a SalesOrder with 3 LineItems (notice that one LineItem has zero quantity), blue arrow pointing to new button("Show Only Current LineItems"): If the User clicks this new button then : a) LineItems with zero quantity will be filtered out, in the image below you can see only 2 LineItems b) the label of the button will be updated to "Show All LineItems" , see the following image: Let's start DAXing...

Send Email to multiple recipients using .Net in Dynamics AX

Here is the way to Send Email to multiple recipients using .Net in Dynamics AX: System.Net.Mail.MailMessage mailMessage; System.Net.Mail.SmtpClient smtpClient; str SmtpServer; str sub, body, to, fromAddr; ; sub = "Test Email" ; body = "Testing Email, Plz delete this"; fromAddr = "donotreply@AX-Prod.com"; to = "user1@test.com,user2@test.com"; mailMessage = new System.Net.Mail.MailMessage(fromAddr, to); SmtpServer = "smtpServer"; mailmessage.set_Subject(sub); mailmessage.set_Body(body); smtpClient = new System.Net.Mail.SmtpClient(SMTPServer); smtpClient.Send(mailmessage);

Print report without user dialog

Take a peek at the class EPSendDocument method makeDocument(). This code actually saves a report to a PDF file without any user interaction, but the general concept should work. The code creates the ReportRun directly after loading the Report name into the Args() object. The code that avoids a user dialog is rr.query().interactive(false); and rb.interactive(false);. You'll want to change your PrintJobSettings pjs.setTarget(PrintMedium::Screen);, etc.

How to write code to create Item counting journal line in AX 2009

 InventDim inventDim; InventJournalTrans journalTrans; TmpImportInventJournal tableBuffer; InventJournalTable inventJournal; real lineNum = 1; TmpImportInventJournal tmpTable; // tmpTable here is used to stored item counting data InventJournalName inventJournalName; NumberSeq numberSeq; ; ttsbegin; select forupdate * from inventJournal where inventJournal.JournalId == inventJournalId; select firstonly inventJournalName where inventJournalName.JournalNameId == InventParameters::find().CountJournalNameId; numberSeq = NumberSeq::newGetVoucherFromCode(inventJournalName.VoucherSeqId); while select * from tmpTable { inventDim.clear(); journalTrans.clear(); inventDim.initValue(); inventDim.configId = tmpTable.configId; inventDim.inventBatchId = tmpTable.inventBatchId; inventDim.InventLocationId = tmpTable.InventLocationId; inventDim.inventSerialId = tmpTable....