WorkCalendarSched.schedDate Method [AX 2012]

Returns the first schedDate where the working time is open.

public SchedDate schedDate(
    SchedDirection _schedDirection, 
    SchedDate _schedDateFrom, 
    Days _days, 
    CalendarDays _calendarDays, 
    CalendarId _calendarId, 
   [CalendarId _secondaryCalendarId, 
    SalesCheckForPickup _checkForPickup])

Run On



Type: SchedDirection Enumeration
Determines whether the date should be calculated backward or forward from the _schedDateFrom.
Type: SchedDate Extended Data Type
The from date upon which calculations are based.
Type: Days Extended Data Type
The lead time.
Type: CalendarDays Extended Data Type
Determines whether to consider open and closed days when you add lead time to the from date to acquire the first schedDate.
Type: CalendarId Extended Data Type
The ID of primary calendar; optional.
Type: CalendarId Extended Data Type
The ID of secondary calendar; optional.
Type: SalesCheckForPickup Enumeration
Determines whether to check if the schedDate is a pickup date, and in which calendar to check; optional. The default value is SalesCheckForPickup::Never.

Return Value

Type: SchedDate Extended Data Type
The first SchedDate where the working time is open.

If both a primary calendar and a secondary calendar are provided, the schedDate will be the first date where there is an opening in both calendars. By using the argument _checkForPickup, it is possible also to require that the schedDate has to be open for pickup in either the primary calendar or the secondary calendar.

If either of the CalendarId objects that are passed as arguments are blank, the calendar will be treated as a calendar with all days open. This is because of the way the isDateOpen method functions.

To avoid infinite loops where two calendars never have a matching opening, an internal limit of 1,000 days is used. If no open day is found within this limit, the original from date (Arg2) is returned.

The job in the following code creates a WorkCalendarSched object and finds an open day.

static void job_testSchedDate(Args _args) 
    WorkCalendarSched workCalendarSched; 
    SchedDate schedDate; 
    SchedDate schedDateFrom; 
    Days leadTime; 
    CalendarDays calendarDays; 
    CalendarId primCalendar; 
    CalendarId secCalendar; 
    SchedDirection schedDirection; 
    workCalendarSched = new workCalendarSched(); 
    schedDirection = SchedDirection::Forward; 
    leadTime = 4; 
    calendarDays = NoYes::Yes; 
    primCalendar = "STD"; 
    secCalendar  =  "STD"; 
    schedDateFrom = str2Date("16.06.2004", 123); 
    schedDate = workCalendarSched.schedDate(schedDirection, 
                                            // from date 
                                            // LeadTime 
                                            //Use calendardays 
     info(strfmt("Returned SchedDate : %1",schedDate));