{"record":{"id":"ee045817f3508aa8","repo":"pentaho/pentaho-kettle","slug":"the-function-call-getnextworkingday-requires-1-argument-ee0458","errorCode":null,"errorMessage":"The function call getNextWorkingDay requires 1 argument.","messagePattern":"The function call getNextWorkingDay requires 1 argument\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":664,"sourceCode":"        if ( isNull( ArgList[0] ) ) {\n          return null;\n        } else if ( isUndefined( ArgList[0] ) ) {\n          return Context.getUndefinedValue();\n        }\n        java.util.Date dIn = (java.util.Date) Context.jsToJava( ArgList[0], java.util.Date.class );\n        Calendar startDate = Calendar.getInstance();\n        startDate.setTime( dIn );\n        startDate.add( Calendar.DATE, 1 );\n        while ( startDate.get( Calendar.DAY_OF_WEEK ) == Calendar.SATURDAY\n          || startDate.get( Calendar.DAY_OF_WEEK ) == Calendar.SUNDAY ) {\n          startDate.add( Calendar.DATE, 1 );\n        }\n        return startDate.getTime();\n      } catch ( Exception e ) {\n        throw Context.reportRuntimeError( e.toString() );\n      }\n    } else {\n      throw Context.reportRuntimeError( \"The function call getNextWorkingDay requires 1 argument.\" );\n    }\n  }\n\n  public static Object dateAdd( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    if ( ArgList.length == 3 ) {\n      try {\n        if ( isNull( ArgList, new int[] { 0, 1, 2 } ) ) {\n          return null;\n        } else if ( isUndefined( ArgList, new int[] { 0, 1, 2 } ) ) {\n          return Context.getUndefinedValue();\n        }\n        java.util.Date dIn = (java.util.Date) Context.jsToJava( ArgList[0], java.util.Date.class );\n        String strType = Context.toString( ArgList[1] ).toLowerCase();\n        int iValue = (int) Context.toNumber( ArgList[2] );\n        Calendar cal = Calendar.getInstance();\n        cal.setTime( dIn );\n        if ( strType.equals( \"y\" ) ) {","sourceCodeStart":646,"sourceCodeEnd":682,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L646-L682","documentation":"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.","triggerScenarios":"Calling getNextWorkingDay() with no arguments, or with extra arguments such as a format string or holiday list.","commonSituations":"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.","solutions":["Call with exactly one Date argument: getNextWorkingDay(myDate)","Convert string dates to Date objects first (e.g. str2date(...)) before passing","Remove any extra parameters from the call"],"exampleFix":"// before\nvar next = getNextWorkingDay(d, 'yyyy-MM-dd');\n// after\nvar next = getNextWorkingDay(d);","handlingStrategy":"type-guard","validationCode":"if (!(d instanceof Date)) d = str2date(String(d), 'yyyy-MM-dd');\nvar next = getNextWorkingDay(d);","typeGuard":"function isDate(v) { return v != null && v instanceof Date && !isNaN(v.getTime()); }","tryCatchPattern":"try { var next = getNextWorkingDay(d); } catch (e) { Alert('getNextWorkingDay: ' + e.message); }","preventionTips":["Pass exactly one Date, no format or config parameters","Convert string fields to Date before calling","Keep the call on its own line so argument count is obvious"],"tags":["javascript","kettle","date","argument-count"],"backgroundTag":"missing-required-argument","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}