pentaho/pentaho-kettle · error

The function call getNextWorkingDay requires 1 argument.

Error message

The function call getNextWorkingDay requires 1 argument.

What it means

getNextWorkingDay is a Kettle Rhino extension function that returns the timestamp of the next working (business) day after the given date. It requires exactly 1 argument (a Date). Any other argument count triggers this RuntimeError.

Solutions

  1. Call with exactly one Date argument: getNextWorkingDay(myDate)
  2. Convert string dates to Date objects first (e.g. str2date(...)) before passing
  3. Remove any extra parameters from the call

Example fix

// before
var next = getNextWorkingDay(d, 'yyyy-MM-dd');
// after
var next = getNextWorkingDay(d);
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(d instanceof Date)) d = str2date(String(d), 'yyyy-MM-dd');
var next = getNextWorkingDay(d);

Type guard

function isDate(v) { return v != null && v instanceof Date && !isNaN(v.getTime()); }

Try / catch

try { var next = getNextWorkingDay(d); } catch (e) { Alert('getNextWorkingDay: ' + e.message); }

Prevention

When it happens

Trigger: Calling getNextWorkingDay() with no arguments, or with extra arguments such as a format string or holiday list.

Common situations: Copy-pasted script fragments expecting a locale/calendar parameter; calling the function inside a string concatenation and accidentally passing the concatenated string as a second argument.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/ee045817f3508aa8. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:664

        if ( isNull( ArgList[0] ) ) {
          return null;
        } else if ( isUndefined( ArgList[0] ) ) {
          return Context.getUndefinedValue();
        }
        java.util.Date dIn = (java.util.Date) Context.jsToJava( ArgList[0], java.util.Date.class );
        Calendar startDate = Calendar.getInstance();
        startDate.setTime( dIn );
        startDate.add( Calendar.DATE, 1 );
        while ( startDate.get( Calendar.DAY_OF_WEEK ) == Calendar.SATURDAY
          || startDate.get( Calendar.DAY_OF_WEEK ) == Calendar.SUNDAY ) {
          startDate.add( Calendar.DATE, 1 );
        }
        return startDate.getTime();
      } catch ( Exception e ) {
        throw Context.reportRuntimeError( e.toString() );
      }
    } else {
      throw Context.reportRuntimeError( "The function call getNextWorkingDay requires 1 argument." );
    }
  }

  public static Object dateAdd( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {
    if ( ArgList.length == 3 ) {
      try {
        if ( isNull( ArgList, new int[] { 0, 1, 2 } ) ) {
          return null;
        } else if ( isUndefined( ArgList, new int[] { 0, 1, 2 } ) ) {
          return Context.getUndefinedValue();
        }
        java.util.Date dIn = (java.util.Date) Context.jsToJava( ArgList[0], java.util.Date.class );
        String strType = Context.toString( ArgList[1] ).toLowerCase();
        int iValue = (int) Context.toNumber( ArgList[2] );
        Calendar cal = Calendar.getInstance();
        cal.setTime( dIn );
        if ( strType.equals( "y" ) ) {

View on GitHub (pinned to f3058517a1)