{"record":{"id":"bc1cd92a3aa2bddb","repo":"pentaho/pentaho-kettle","slug":"the-function-call-isworkingday-requires-1-argument-bc1cd9","errorCode":null,"errorMessage":"The function call isWorkingDay requires 1 argument.","messagePattern":"The function call isWorkingDay 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":491,"sourceCode":"        if ( isNull( ArgList[0] ) ) {\n          return null;\n        } else if ( isUndefined( ArgList[0] ) ) {\n          return Context.getUndefinedValue();\n        } else {\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          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 Context.reportRuntimeError( \"The function call isWorkingDay requires 1 argument.\" );\n    }\n  }\n\n  @SuppressWarnings( \"unused\" )\n  public static Object fireToDB( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n\n    Object oRC = new Object();\n    if ( ArgList.length == 2 ) {\n      try {\n        Object scmO = actualObject.get( \"_step_\", actualObject );\n        ScriptValuesMod scm = (ScriptValuesMod) Context.jsToJava( scmO, ScriptValuesMod.class );\n        String strDBName = Context.toString( ArgList[0] );\n        String strSQL = Context.toString( ArgList[1] );\n        DatabaseMeta ci = DatabaseMeta.findDatabase( scm.getTransMeta().getDatabases(), strDBName );\n        if ( ci == null ) {\n          throw Context.reportRuntimeError( \"Database connection not found: \" + strDBName );\n        }","sourceCodeStart":473,"sourceCodeEnd":509,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L473-L509","documentation":"Arity guard for isWorkingDay: the function takes exactly one java.util.Date argument and checks whether it falls Monday-Friday. Null/undefined are special-cased; only an invalid argument count triggers this throw.","triggerScenarios":"isWorkingDay() with no arguments, or two arguments (e.g. date plus a holiday calendar) in a Modified Java Script Value step.","commonSituations":"Assuming a second argument for a custom holiday list; testing the function without arguments; arguments removed during script editing.","solutions":["Call isWorkingDay with exactly one date argument: isWorkingDay(orderDate).","Handle holidays separately in script logic if needed.","Ensure the argument is a Date or date-convertible value."],"exampleFix":"// before\nvar work = isWorkingDay(d, holidays);\n// after\nvar work = isWorkingDay(d) && holidays.indexOf(d.getTime()) < 0;","handlingStrategy":"validation","validationCode":"var d = orderDate instanceof Date ? orderDate : str2date(orderDate, 'yyyy-MM-dd');\nvar work = isWorkingDay(d);","typeGuard":"function isDateArg(v){ return v instanceof Date && !isNaN(v.getTime()); }","tryCatchPattern":null,"preventionTips":["Exactly one date argument; add holiday logic separately.","Ensure dates are real Date objects, not nulls from upstream steps.","Guard with a default date when the field can be null."],"tags":["javascript","argument-count","date","pdi-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"}