SSRS Report – Timeout error for Long running queries in AX2012

“A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond”

To change the report to run in this pre-processing way (Similar to Sales confirmation, Sales Invoice, etc. reports).
see this example below for the Fixed Asset movement report on how to change this:

1. To find which object you need to modify, first look in the AOT >> Menus, for the Menu where the report is
2. View the properties on this to see the associated menu item. You can see below the menu item is “AssetBalancesPeriod”.

3. Find this menu item in AOT >> Menu Items >> Output and look at the properties, make a note of the “LinkedPermissionObject”, in this case “AssetBalancesPeriod”

4. Next in the AOT >> SSRS Reports >> Reports, locate AssetBalancesPeriod, then expand this out until you see the Server Methods. Make a note of the Server Method class, in this case “AssetBalancesPeriodDP”

5. In the AOT >> Classes, locate and open class AssetBalancesPeriodDP.

6. In the AssetBalancesPeriodDP\classDeclaration, change the extend class to SrsReportDataProviderPreProcess instead of SrsReportDataProviderBase

7. Make a note of the Temp table used in the report, as above this is AssetBalancesPeriodTmp.

8. Next, change the method AssetBalancesPeriodDP\processReport to add the following line after the contract:
contract.parmFromDate();
contract.parmtodate();
AssetBalancesPeriodTmp.setConnection(this.parmUserConnection());

9. Next, in AOT > Data Dictionary > Tables, locate the table you made a note of in point 7, so in this case the AssetBalancesPeriodTmp. Change the table properties as follows:

• TableType = Regular

• CreatedBy = Yes

• CreatedTransactionId = Yes

10. Opened AssetBalancesPeriod report in Visual Studio and refreshed the data source to include new field (CreatedTransactionId).

11. Deployed the new AssetBalancesPeriod report.

12. In AX did a Generate Incremental CIL.

13. Restart SSRS

Now this report can run without timeout error.

Dynamics ax 2012 Use of JSON

I’ve recently had a requirement to integrate an external system with Dynamics AX 2012’. Here is a very basic code sample of how to consume JSON using these classes in Dynamics AX 2012.

 static void myJob(Args _args)  
 {   
   RetailWebRequest request;   
   RetailWebResponse response;   
   str rawResponse, value;   
   Map data;   
   RetailCommonWebAPI webApi = RetailCommonWebAPI::construct();   
   request = RetailWebRequest::newUrl("http://mysite.com/jsonaction");   
   response = webApi.getResponse(request);   
   rawResponse = response.parmData();   
   data = RetailCommonWebAPI::getMapFromJsonString(rawResponse);   
   value = data.lookup("elementname");   
   info(strFmt("Element name: %1",value));   
 }  

Thanks

Happy Daxing 🙂

Utility code for creating the Free text invoice (FTI) in AX 2012

Hi Guys,

This post targeting developers and help creating free text invoice from code in dynamics ax 2012

 static void SimpleFtiCreation(Args _args)  
 {  
   custInvoiceTable custInvoiceTable;  
   custInvoiceLine custInvoiceLine;  
   custTable custTable;  
   int lineNum;  
   try  
   {  
     /// <summary>  
     ///   The <c>CustInvoiceTable</c> logic is implemented to create single <c>Header</c>.  
     /// </summary>  
     ttsbegin;  
     custInvoiceTable.clear();  
     custTable = CustTable::find("Test");  
     custInvoiceTable.initFromCustTable(custTable);  
     custInvoiceTable.InvoiceDate = systemDateGet();  
     custInvoiceTable.insert();  
     custInvoiceLine.clear();  
     custInvoiceLine.initValue();  
     custInvoiceLine.initFromCustInvoiceTable(custInvoiceTable);  
     custInvoiceLine.LedgerDimension = 89897878;  
     custInvoiceLine.DefaultDimension = 67676767;  
     custInvoiceLine.Quantity = 100;  
     custInvoiceLine.UnitPrice = 2.5;  
     custInvoiceLine.AmountCur = 250;  
     custInvoiceLine.Description = strFmt("Subscription %1", "Test") ;  
     custInvoiceLine.InvoiceTxt = strFmt("Subscription %1" , "Test") ;  
     custInvoiceLine.ParentRecId = custInvoiceTable.RecId;  
     custInvoiceLine.editReasonCode(true, 'Device Sub');  
     custInvoiceLine.editReasonComment(true, 'Device Subscription');  
     //LINE NUM LOGIC.  
     if(!lineNum)  
     {  
       lineNum = CustInvoiceLine::lastLineNum_W(custInvoiceLine.ParentRecId);  
     }  
     lineNum += 1;  
     custInvoiceLine.LineNum = lineNum;  
     custInvoiceLine.insert();  
     ttscommit;  
     //just to be sure for proper distributions  
     SourceDocumentProcessor::submitSourceDocumentLinesForHeader(custInvoiceTable.SourceDocumentHeader);  
   }  
   catch(exception::Error)  
   {  
   }  
 }  

Consuming Pending Vendor invoice service from C#

This blog refers to consuming or creating Pending vendor invoice record in dynamics ax 2012 R3 using out of box service “VendVendInvoiceService”. The focus of this blog is .net C# side. In this example I took the complex case of creating Vendor invoice that linked to multiple PURCHASE ORDERS in received status.

This ADDHeader method insert record in VendInvoiceInfoTable, for this example I just filled the required ones.

header

This ADDLine method insert a line in VendInvoiceInfoLine table. this is helper method will be called from main executing point.

line

This is the main executing method, In this method I did initialization of required objects, make find call of two purchase order records using Purchase order service (You could do this by any way, hard coded or service call or through .net proxies). Here I am also making the call of AddHeader method to create the header record

methosstart

Further on the same method, call AddLine to create Line record, Also specify the QTY that how much I want to invoice from the receiving, I did the same for both the purchase orders.

beforetry

After composing complete message, making Create call to service

try

Thanks
Amir (Happy Daxing)