Skip to main content

Posts

Showing posts with the label axapta

How to get the current company(Legal Entity) address in Axapta 2012 based on the Address Type

How to get the current company(Legal Entity) address in Axapta 2012 based on the Address Type?: In single line of code:   static void getAddressBasedOnPurposeForLegalEntity(Args _args) {     LogisticsAddressing  address;     ;          address = DirParty::findPostalAddressByRole(CompanyInfo::current(), LogisticsLocationRoleType::RemitTo).Address;     info(address);      }

Group By and Aggregation (Sum) in RunTime Query:

Group By and aggregation as Sum in RunTime Query:     Query query;     QueryRun queryRun;     QueryBuildDataSource ds;     QueryBuildRange range1;     CustAccount     accountNum;     CustTrans custTrans;         query = new Query();     ds = query.addDataSource(tableNum(CustTrans));     ds.addGroupByField(fieldNum(CustTrans, AccountNum));        range1 = SysQuery::findOrCreateRange(ds, fieldNum(CustTrans, AccountNum));     range1.value(queryValue(accountNum));        ds.addSelectionField(fieldNum(CustTrans, AmountMST),SelectionField::Sum);

How to Store an image in container in axapta

how to store image in container : Create a field in table of Type contianer which must extend EDT:Bitmap code: public Bitmap getImage() {     Bitmap bitmap;     Bindata     binData ;     FileIOPermission perm;     FilePath _filepath = "c:\\sample.jpg"     ;     perm = new FileIOPermission(_filePath, 'r');     perm.assert();     binData = new BinData();     if (binData.loadFile(_filepath))     {         bitmap = binData.getData();     }     CodeAccessPermission::revertAssert();     return bitmap; } after that you assign this method to contianer  = > table.Field = class.getImage()

Store and retrieve an image in a table for a record in AX

The simplest way to store an image for a record into AX tables is by using the CompanyImage Menu Item. I will explain you with an example below: Generally, most of the customers would request for a functionality to store an image for an item. For this, there is no need of high customization. Initially, Goto the Design in InventTable Form and add a Display Menu Item called CompanyLogo to its button Group. Change the label of the Menu item button in the form. Now, open the InventTable form and click on the menu item and load an image associated with a record. This image will be stored in the CompanyImage table as a BLOB in a container with the refRecId, RefTableId and RefCompanyId of the associated record(Here Record of InventTable). Retrieving it and saving to file system again is pretty easy with the help of binData Class. Here is the supporting code snippet.... bindata   bin = new bindata(); str    content; container image; InventTable inventT...

Better business insight with Microsoft Dynamics AX 2012 R2

Many organizations struggle with providing business insight in a timely manner as resource-constrained IT departments can’t keep up with the requests from business users. Far too often users are spending too much unproductive time creating manual reports that are static and outdated. Facing ever-accelerating change and the pressure from more prevalent global competition, it is more important than ever that organizations have instant access to up-to-date financial and operational performance to spot trends and identify challenges so they can act early. In previous versions of Microsoft Dynamics AX we enabled business intelligence as part of the ERP experience. The business user can access important information throughout the solution, via Role Center pages, which are dashboards that provide an overview of information that pertains to a user’s job function and by using Microsoft BI technology such as Microsoft Excel. In Microsoft Dynamics AX 2012 R2 we further improved the BI capa...

How to send emails from AX without requiring Outlook

Sending emails from AX has been somewhat of a pain when it tries to use Outlook. This post is a simple code modification to one method in \Classes\Info\reportSendMail. I did not develop this code, I merely tweaked it. The original poster's blog has disappeared, and I can only find non-working remnants all around the web of this, but it is just too useful not to repost. If you have Outlook 64bit edition, you might get the "Either there is no default mail client or the current mail client cannot fulfill the messaging request. Please run Microsoft Outlook and set it as the default mail client." Followed by an AX MAPI error. Or sometimes you may get the "A program is trying to access e-mail address information stored in Outlook."...Allow/Deny/Hlep. This change basically bypasses outlook. Put it in and give it a shot. void reportSendMail(PrintJobSettings p1) { //SysINetMail m = new SysINetMail(); System.Net.Mail.MailMessage mailM...

AX 2012 SSRS Report: Multiple report design under Print management

AX 2012 SSRS Report: Multiple design under Print management If new formats for Sales order confirmation/Picking/Packing/Invoice Purchase order postings etc. are needs to be added. Following steps needs to be performed. Step1. Create new Design for report under visual studio Step2. Add code to method: \Data Dictionary\Tables\PrintMgmtReportFormat\Methods\populate Add Code in the before TTSCOMMIT: addOther(PrintMgmtDocumentType::SalesOrderPackingSlip, ‘SalesPackingSlip.Report_XYZ,’SalesPackingSlip.Report_XYZ’ ,’XYZ’); Step 3. Setup the Format under: AR -> setup -> form setup -> Print management -> Sales order Packing slip original -> report format to SalesPackingslip.Report_XYZ Step 4. New Report design can be executed from use Print management from Inquiry journal forms or during posting by selecting Print management destination.

Save SSRS report to pdf that uses Controller classes [Dynamics AX 2012]

static   void  SR_SaveReportToPDFFromController(Args _args) {     SalesInvoiceController  salesInvoiceController;     SalesInvoiceContract    salesInvoiceContract;     Args                    args =  new  Args();     SrsReportRunImpl        srsReportRun;     CustInvoiceJour         custInvoiceJour;     ReportName              reportName =  "SalesInvoice.Report" ;     ;      select   firstOnly  custInvoiceJour;     args.record(custInvoiceJour);      ...

Dynamics AX – Periodic maintenance and performance analysis

1 Periodic clean up - Significance A recent AX_Database analysis showed that the 5 largest tables in the database account for roughly 60% of the database size. The 4 largest tables out of 5 are tables with temporary and/or archival data: Inventory settlements (INVENTSETTLEMENT), database log (SYSDATABASELOG), temporary sales orders data (SALESPARMLINE), temporary master planning data (INVENTSUMLOGTTS). The fifth table is sales lines (SALESLINE). Periodically archiving/purging these tables would significantly reduce database size and will have beneficial effect on system performance . Each individual table and related considerations are discussed below: 1.1   Inventory settlements . The inventory settlements table is used to store information generated during inventory close and adjust periodic job run. This table can be cleaned up/compressed using the Inventory management>Periodic>Clean up>Inventory settlements clean up. Deleting cancelled settlement is a r...

AXAPTA Ana tablo formuna git

Go to the Main Table Form has to be implemented manually. In this recipe, to demonstrate how it works, we will modify the Business relations form in the CRM module to make sure that the Employee filter at the top of the form allows users to use the Go to the Main Table Form feature from the context menu. 1. Open the formform in AOT, and override jumpRef() of the EmployeeFilter control with: "Ana tablo formuna git" butonu otomatik olarak çalışır. Ancak kontrol sadece extended data tipine bağlıysa, çalışmaz. Bu durumda kendi Jumpref methodunuzu yazmanız gerekir. Bu konuda Fatih Demirci 'nin aşağıdaki kodundan faydalandım: public void jumpRef() { EmplTable emplTable; Args args; MenuFunction menuFunction; ; emplTable = EmplTable::find(this.text()); if (!emplTable) { return; } args = new Args(); args.caller(element); args.record(emplTable); menuFunction = new MenuFunction( menuitemdisplaystr(EmplTable), MenuItemType::Display); menuFunction.run(...

Force delete inventtrans

Below is sample job to force delete inventtrans, which will take care of invent on hand update. static void DeleteInventTrans(Args _args) { Dialog dlg = new Dialog("Delete inventtrans ?"); DialogField dlgFld; InventMovement inventMovement; PurchLine purchLine; PurchLineRefRecId recId; ; dlgFld = dlg.addField(typeid(PurchLineRefRecId)); if(dlg.run()) { recId = dlgFld.value(); purchLine = PurchLine::findRecId(recId); if(purchLine) { InventMovement = InventMovement::construct(purchLine); InventUpd_DeleteMovement::newMovement( inventMovement,true).updateNow(); info("done"); } } }

Execute SQL command

static void Job3 ( Args _args ) {     LogInProperty   Lp = new LogInProperty ( ) ;     OdbcConnection  myConnection;     Statement       myStatement;     ResultSet       myResult;     str             sqlQuery; ;     sqlQuery = 'SELECT TOP 10 * FROM CustTable ORDER BY NewID()' ;     LP. setServer ( "Server" ) ;     LP. setDatabase ( "db" ) ;     Lp. setUsername ( "user" ) ;     Lp. setPassword ( "password" ) ;     try {         myConnection = new OdbcConnection ( LP ) ;     }     catch {         info ( "Check username/password." ) ;         return ;     }     myStatement = myConnection. createStatement ( ) ;     myResult = myStatement. executeQuery ( sqlQuery ) ;   ...

Purchline Change confirmed date Axapta

void clicked ( ) {   PurchLine                 tmpPurchLine;   PurchLine                 updatePurchLine;   PurchLine                 selectedRecord;   Dialog            dl;   DialogField       dlfTransdate; ;     dl   = new Dialog ( "Change confirmed date" ) ;     dlfTransdate = dl. addFieldValue ( typeid ( "Transdate" ) , today ( ) , "Confirmed date" ) ;     if ( dl. run ( ) ) {         selectedRecord =  PurchLine_ds. cursor ( ) ;         for ( tmpPurchLine = PurchLine_ds. getFirst ( true ) ? PurchLine_ds. getFirst ( true ) : PurchLine_ds. cursor ( ) ;         tmpPurchLine;    tmpPurchLine = PurchLine_ds. getnext ( ) )         {     ...

Microsoft Dynamics AX 2012 Source to Target data upgrade

What is this feature ? The source to target upgrade model provides a framework to reduce the downtime for AX upgrade.The upgrade downtime is achieved by enabling upgrade on both the source AX system (Ax 4.0 or AX 2009) and target AX system (Ax 2012). The upgrade consists of following steps. 1. Pre-upgrade processing on a live source AX system 2. Bulk data copy to target system, 3. Optimized data transformations (write once per table), and sync-on-the-fly to the target AX 2012 4. Fix duplicate RecID as a part of the upgrade process How do we upgrade using this feature ? The user installs an XPO on the source AX system being upgraded, launches the pre-upgrade checklist, and walks through the pre-upgrade checklist items. Most of the checklist tasks can be executed on a live AX system and rest within a single user mode. Concurrently the user can setup the AX 2012 environment for upgrade by installing AX 2012, choosing the upgrade option, and then launching the upgrade checklist an...

How to update vendor addresses in Dynamics AX 2009

static void  UpdateVendAddressType(Args _args) { VendTable      vendTab; // Replace VendTable with CustTable when run this for  customers. DirPartyTable dirPartyTab; Address           addTab; ; ttsbegin; while select vendTab join dirPartyTab join forupdate addTab where vendTab.PartyId == dirPartyTab.PartyId && addTab.AddrTableId == dirPartyTab.TableId && addTab.AddrRecId == dirPartyTab.RecId {       if(addTab.Name == ‘Birincil Adres’)      {         addTab.type = AddressType::Payment;         addTab.update();      } } ttscommit; }

Merging Two records

//we will explore how to correct such a situation by merging two records including //all their related transactions. For the demonstration, we will merge two vendor accounts 5001 //and 5002 into a single one, that is, 5001. static void VendAccountMerge(Args _args) { VendTable vendTable; VendTable vendTableDelete; PurchJournalAutoSummary jourSummary; #define.vend('5001') #define.vendDelete('5002') ;      ttsbegin; delete_from jourSummary where jourSummary.VendAccount == #vendDelete; select firstonly forupdate vendTableDelete where vendTableDelete.AccountNum == #vendDelete; select firstonly forupdate vendTable where vendTable.AccountNum == #vend; vendTableDelete.merge(vendTable); vendTable.doUpdate(); vendTableDelete.doDelete();      ttscommit; }

Exporting data to Excel

As there are merits of a solution which depend on the situations and conditions in which they are used, I am suggesting one more alternate for achieving the objective i.e. Exporting data to Excel. In this solution we will make use of standard AX’s Reports and the concept of exporting the report data to an Excel file. I assume that we all understand that any standard AX report can be sent to a variety of Output devices such as Printer,Screen,Fax,File ( CSV,TXT,PDF,EXCEL etc) . The disadvantage in this is that the report headers is repeated after every page break and that is an undesired part . In the following walkthrough we will get over this problem as well as restrict the output to a file so that it gives a look and feel of an data export functionality. We will create a sample report for exporting the Price agreements data to Excel Start creating a report in AOT as per the following steps : Step 1: Create a class as shown below in which we would declare objects. ...