Skip to main content

Posts

How Exception handling Try/Catch statements work in AX

A sample code for Try/Catch statements in AX under run method in a class. public void run() {     #OCCRetryCount         try     {             }     catch (Exception::Deadlock)     {         retry ;     }     catch (Exception::UpdateConflict)     {         if (appl.ttsLevel() == 0 )         {             if (xSession::currentRetryCount() >= #RetryNum)             {                 throw Exception::UpdateConflictNotRecovered;        ...

Signing limits for Business Documents in AX 2012

A signing limit defines the largest financial commitment that a worker is authorized to make on behalf of an employer. There are two types of signing limits — spending limits and approval limits . A spending limit is the maximum amount a worker is authorized to spend on business-related purchases. An approval limit is the maximum amount a worker is authorized to approve for a specific business document when the document is submitted to workflow. The limits are associated with a worker's job or compensation level. Signing limits can also vary depending on the transaction type — purchase requisitions , expense reports , purchase orders , and invoices can have different signing limits. Signing Limit Parameters Organizations assign default signing limits. Depending on the configuration of signing limits in an organization, a worker can obtain a default signing limit in one of the following ways. The worker is automatically assigned the default signing limit...

SSRS report expressions - compiled and ongoing

How to get full AX company in SSRS report =Microsoft.Dynamics.Framework.Reports.DataMethodUtility.GetFullCompanyNameForUser(Parameters!AX_CompanyName.Value, Parameters!AX_UserContext.Value) How to show alternate row colour in SSRS report Set following expression to row’s background property =IIf(RowNumber(Nothing) Mod 2 = 0, "LightGrey", "WhiteSmoke") How to format a date =format(Parameters!Dataset1_AsPerDate.Value, "dd/MM/yyyy" ) How to show date and time on report =Microsoft.Dynamics.Framework.Reports.DataMethodUtility.ConvertUtcToAxUserTimeZoneForUser(Parameters!AX_CompanyName.Value, Parameters!AX_UserContext.Value, System.DateTime.UtcNow, "d" , Parameters!AX_RenderingCulture.Value) & " at " & Microsoft.Dynamics.Framework.Reports.DataMethodUtility.ConvertUtcToAxUserTimeZoneForUser(Parameters!AX_CompanyName.Value, Parameters!AX_UserContext.Value, System.DateTime.UtcNow, "t" , Paramete...

Debug/Test SSRS report in AX 2012

People came across issues like report is not showing data on report or data is not per their expectation. It is really hard to judge where it goes wrong and what needs to be correct in which class RDP, Contract, UI or Controller. Following sample job can be used to debug SSRS report processing data and lead to find what goes unexpected. For more information about classes and table used in this example please read my previous post static void FF_ReportDPTest(Args _args) {     // temp table declaration     FF_ReportTmpTable       ffReportTmp;     // RDP class binded with FF_Report     FF_ReportDP             dataProvider = new FF_ReportDP();     // Contract class for report parameters     FF_ReportContract       contract = new FF_ReportContract(); ...

Run SSRS report from AX form

Continue from my previous post where I developed an example using all SSRS framework classes. One of them is controller class which is used to call SRS report from AX forms. Just for the note controller class is used for following purposes. Modifying a report query based on the input data Modifying report contract data based on the input data Control a report parameters dialog Open different reports/designs from the same menu item based on the input data Reports that are opened from a form Example; how to call report from AX form button/menuitembutton click void clicked() {     CustOpenInvoices        custOpenInvoicesLocal;     SrsReportRunController  controller = new FF_ReportController();     SrsReportDataContract   contract;     FF_ReportContract       rdpContractClass;   ...

Customise code tagging in AX 2012 – MS Dynamics AX Best practice

Code commenting is one of the best practice for any software development which really helps other team mates or future developers to understand code quickly. Code comments should be enough expounding for others. MS Dynamics AX provides diverse possibilities to comment out code in much better and generic way through scripts. This can be used by right click in any method within AOT objects as shown; Here we also have tagging option to use generic way to comment out our code and this could be really helpful when working on big projects. MS Dynamics AX uses a class EditorScript behind these scripts tool, I added a following method under this class for specific code comment pattern. public void tagging_CodeModifications(Editor editor) {     #Define.NextLine( '\n' )     int currentLineNo = editor.selectionStartLine();     int currentCol    = editor.selectionStartCol();   ...

Business/Working days in AX

Following job is to calculate business days/working days in AX using base calendars. In my case base calendar name is "24/5" you can change it as per your setup. static void businessdaysInPeriod(Args _args) {     WorkCalendarSched workCalendarSched;     date start;     date end;     counter workingdays;     counter totaldays;     CalendarId primCalendar= "24/5" ;     ;     start = str2date ( "21-11-2014" , 123 );     end   = str2Date ( "26-11-2015" , 123 );     workCalendarSched = new workCalendarSched();     while (start<=end)     {         totaldays++;         if (workCalendarSched.isdateopen(primCalendar,start)== true )         {  ...