{"record":{"id":"950ad0192635c9d1","repo":"pentaho/pentaho-kettle","slug":"the-function-call-isworkingday-requires-1-argument","errorCode":null,"errorMessage":"The function call isWorkingDay requires 1 argument.","messagePattern":"The function call isWorkingDay 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":473,"sourceCode":"        if ( isNull( ArgList[0] ) ) {\n          return null;\n        } else if ( isUndefined( ArgList[0] ) ) {\n          return undefinedValue;\n        } else {\n          java.util.Date dIn = (java.util.Date) ArgList[0];\n          Calendar startDate = Calendar.getInstance();\n          startDate.setTime( dIn );\n          if ( startDate.get( Calendar.DAY_OF_WEEK ) != Calendar.SATURDAY\n            && startDate.get( Calendar.DAY_OF_WEEK ) != Calendar.SUNDAY ) {\n            return Boolean.TRUE;\n          }\n          return Boolean.FALSE;\n        }\n      } catch ( Exception e ) {\n        return null;\n      }\n    } else {\n      throw new RuntimeException( \"The function call isWorkingDay requires 1 argument.\" );\n    }\n  }\n\n  @SuppressWarnings( \"unused\" )\n  public static Object fireToDB( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object FunctionContext ) {\n\n    Object oRC = new Object();\n    if ( ArgList.length == 2 ) {\n      try {\n        Object scmO = actualObject.get( \"_step_\" );\n        Script scm = (Script) scmO;\n        String strDBName = (String) ArgList[0];\n        String strSQL = (String) ArgList[1];\n        DatabaseMeta ci = DatabaseMeta.findDatabase( scm.getTransMeta().getDatabases(), strDBName );\n        if ( ci == null ) {\n          throw new RuntimeException( \"Database connection not found: \" + strDBName );\n        }","sourceCodeStart":455,"sourceCodeEnd":491,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L455-L491","documentation":"isWorkingDay(date) checks whether a given date falls on a working day. It requires exactly one argument; any other argument count throws this RuntimeException. On internal evaluation errors it returns null instead of throwing, so this message only appears for wrong arity.","triggerScenarios":"Calling isWorkingDay() with zero arguments or two or more arguments from script code in a Script step.","commonSituations":"Passing both a date and a format string; forgetting the argument entirely; converting code that used a different helper with multiple parameters.","solutions":["Pass exactly one Date argument: isWorkingDay(myDate).","Ensure the argument is a Date object (parse strings to Date first).","Use nextWorkingDay/dateDiff helpers only with their documented signatures."],"exampleFix":"// before\nvar wd = isWorkingDay('2026-01-05');\n// after\nvar wd = isWorkingDay(new Date('2026/01/05'));","handlingStrategy":"type-guard","validationCode":"if (myDate instanceof Date) { var wd = isWorkingDay(myDate); }","typeGuard":"function isDate(v) { return v instanceof Date && !isNaN(v.getTime()); }","tryCatchPattern":"try { var wd = isWorkingDay(myDate); } catch (e) { if (/isWorkingDay requires 1 argument/.test(String(e))) { wd = null; } else { throw e; } }","preventionTips":["Pass exactly one Date object.","Handle null upstream fields before the script step.","Avoid wrapping extra context values into the call."],"tags":["javascript","script-step","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"}