Monday, 13 April 2020

D365FO: How to check Standard Base Enum values of D365 FO which are not visible in AOT properties?


In D365FO, if you cannot find integer values of standard Base Enum.

You can easily find it on MS SQL Server using the following code.

select * from ENUMIDTABLE             
join ENUMVALUETABLE
ON ENUMVALUETABLE.ENUMID = ENUMIDTABLE.ID
where ENUMIDTABLE.NAME = 'InventTransType'



Tuesday, 10 March 2020

How to get forward and backward working date from current date in AX D365?


In AX D365, there are a lot of date methods to get a particular date of day month or year. If u want to get a forward date/backward date of working days only. The following code will help you to achieve your target.

    /// <summary>

    /// Runs the class with the specified arguments.
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    { 
        WorkCalendarSched       workCalendarSched;
        SchedDate               schedDateFrom, resultantTODate;
        Days                    noOfDays;
        CalendarId              primCalendar, secCalendar;

        workCalendarSched = new workCalendarSched();

        noOfDays            = 30;
        primCalendar        = "Default";   
        secCalendar         = "Default";
        schedDateFrom       = str2Date("31.1.2019", 123);    // dd.mm.yyyy

        info(strfmt("From date: %1",
        date2str(schedDateFrom, 123, DateDay::Digits2, DateSeparator::Slash,
     DateMonth::Short, DateSeparator::Slash, DateYear::Digits4)));
        
        info(strFmt("Adding %1 days [Working days]", noOfDays));
        resultantTODate = workCalendarSched.schedDate(  SchedDirection::Forward, // Selecting backward will minus the noOfDays
                                                        schedDateFrom,
                                                        noOfDays,                   // number of days to add
                                                        NoYes::Yes,                 // Yes mean bring WorkDays        (exclude weekEnds and other configured holidays in between)
                                                        primCalendar, secCalendar); // which calendar to be used for date calculation and verification
        info(strfmt("Resultant TO date: %1",
        date2str(resultantTODate, 123, DateDay::Digits2, DateSeparator::Slash, DateMonth::Short, DateSeparator::Slash, DateYear::Digits4)));

    }

Below is the screenshot of code run of AX D365 F&O



Wednesday, 12 February 2020

Suppress BP Warnings

When using the Microsoft Dynamics AX development environment, you should adhere to a set of best practices. The X++ compiler checks the code for best practice issues. These issues can result in best practice errors, warnings, or informational messages. There are some warnings which we need to suppress or hide from the BP errors Check List. In order to do this we will have to follow these steps.
For Example: You need to suppress a warning like mentioned below.

BP RULE: [BPPARAMETERNOTUSED]:THE PARAMETER ‘E’ IS NOT USED.

  1. Get the name of warning, in my case the above green highlighted characters are my warning name.
  2. Get Ready the reason for suppress. The below red highlighted characters are the reason. You can change the reason according to your own situation.
  3. [SuppressBPWarning(“BPParameterNotUsed“, “Parameter required by the event interface“)]
  4. Use the above header (point no 3) before any method of class as you can see in below attached picture.
    Capture5a.PNG