{"record":{"id":"da4a477ecadfeaff","repo":"pentaho/pentaho-kettle","slug":"the-function-call-getnextworkingday-requires-1-argument","errorCode":null,"errorMessage":"The function call getNextWorkingDay requires 1 argument.","messagePattern":"The function call getNextWorkingDay requires 1 argument\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java","lineNumber":634,"sourceCode":"        if ( isNull( ArgList[0] ) ) {\n          return null;\n        } else if ( isUndefined( ArgList[0] ) ) {\n          return undefinedValue;\n        }\n        java.util.Date dIn = (java.util.Date) ArgList[0];\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 new RuntimeException( e.toString() );\n      }\n    } else {\n      throw new RuntimeException( \"The function call getNextWorkingDay requires 1 argument.\" );\n    }\n  }\n\n  public static Object dateAdd( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object 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 undefinedValue;\n        }\n        java.util.Date dIn = (java.util.Date) ArgList[0];\n        String strType = ( (String) ArgList[1] ).toLowerCase();\n        int iValue = (Integer) ArgList[2];\n        Calendar cal = Calendar.getInstance();\n        cal.setTime( dIn );\n        if ( strType.equals( \"y\" ) ) {","sourceCodeStart":616,"sourceCodeEnd":652,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L616-L652","documentation":"ScriptAddedFunctions.getNextWorkingDay is a JavaScript-callable helper exposed to Pentaho Kettle's JavaScript step. It computes the next working day from a date argument, but only when exactly one argument is passed in ArgList. When called with zero or more than one argument it throws this RuntimeException instead of computing a result.","triggerScenarios":"Calling getNextWorkingDay() with no arguments, or getNextWorkingDay(date, extra) with two or more arguments, from JavaScript code inside a Modified Java Script Value / Script step.","commonSituations":"Copy-pasted JavaScript snippets that pass a format string alongside the date; missing variable binding so the date argument evaluates to nothing; misunderstanding that the function takes only the source date and no options object.","solutions":["Pass exactly one argument: getNextWorkingDay(new Date()) or getNextWorkingDay(dateField).","Check for typos or stray commas creating extra arguments in the JavaScript call.","If you need extra options, compute them in JavaScript before calling, not as extra arguments.","Verify the date variable is actually bound in the script step's field list before the call."],"exampleFix":"// before\nvar nextDay = getNextWorkingDay(dateField, 'yyyy-MM-dd');\n// after\nvar nextDay = getNextWorkingDay(dateField);","handlingStrategy":"validation","validationCode":"// JavaScript in the Kettle script step\nif (arguments.length !== 1 || dateField === undefined || dateField === null) {\n  throw new Error('getNextWorkingDay requires exactly one date argument');\n}\nvar nextDay = getNextWorkingDay(dateField);","typeGuard":"function isDateArg(v) { return v instanceof Date || typeof v === 'number' || typeof v === 'string'; }","tryCatchPattern":"try {\n  var nextDay = getNextWorkingDay(dateField);\n} catch (e) {\n  if (String(e.message).indexOf('requires 1 argument') !== -1) {\n    // fix call site: pass exactly one date\n  } else { throw e; }\n}","preventionTips":["Always call getNextWorkingDay with exactly one argument.","Check argument count after editing/copy-pasting script code.","Keep date transformations in dedicated test transformations before production use."],"tags":["javascript","argument-count","pentaho-kettle"],"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"}