{"record":{"id":"c418f00ac7b09e44","repo":"pentaho/pentaho-kettle","slug":"the-function-call-getfiscaldate-requires-2-arguments-c418f0","errorCode":null,"errorMessage":"The function call getFiscalDate requires 2 arguments.","messagePattern":"The function call getFiscalDate requires 2 arguments\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":257,"sourceCode":"        Calendar startDate = Calendar.getInstance();\n        Calendar fisStartDate = Calendar.getInstance();\n        Calendar fisOffsetDate = Calendar.getInstance();\n        startDate.setTime( dIn );\n        Format dfFormatter = new SimpleDateFormat( \"dd.MM.yyyy\" );\n        String strOffsetDate = Context.toString( ArgList[1] ) + String.valueOf( startDate.get( Calendar.YEAR ) );\n        java.util.Date dOffset = (java.util.Date) dfFormatter.parseObject( strOffsetDate );\n        fisOffsetDate.setTime( dOffset );\n\n        String strFisStartDate = \"01.01.\" + String.valueOf( startDate.get( Calendar.YEAR ) + 1 );\n        fisStartDate.setTime( (java.util.Date) dfFormatter.parseObject( strFisStartDate ) );\n        int iDaysToAdd = (int) ( ( startDate.getTimeInMillis() - fisOffsetDate.getTimeInMillis() ) / 86400000 );\n        fisStartDate.add( Calendar.DATE, iDaysToAdd );\n        return fisStartDate.getTime();\n      } catch ( Exception e ) {\n        throw Context.reportRuntimeError( e.toString() );\n      }\n    } else {\n      throw Context.reportRuntimeError( \"The function call getFiscalDate requires 2 arguments.\" );\n    }\n\n  }\n\n  public static double getProcessCount( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n\n    if ( ArgList.length == 1 ) {\n      try {\n        Object scmO = actualObject.get( \"_step_\", actualObject );\n        StepInterface scm = (StepInterface) Context.jsToJava( scmO, StepInterface.class );\n        String strType = Context.toString( ArgList[0] ).toLowerCase();\n\n        if ( strType.equals( \"i\" ) ) {\n          return scm.getLinesInput();\n        } else if ( strType.equals( \"o\" ) ) {\n          return scm.getLinesOutput();\n        } else if ( strType.equals( \"r\" ) ) {","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L239-L275","documentation":"getFiscalDate computes a fiscal-calendar date by shifting a given date a number of days; the ScriptValuesMod step requires exactly 2 arguments (a Date and the day count). When ArgList.length != 2 it throws this Rhino runtime error.","triggerScenarios":"Calling getFiscalDate(date) with one argument, or with three, in a Modified Java Script Value step.","commonSituations":"Forgetting the second argument (days to add); passing arguments separated by the wrong delimiter so they parse as one; assuming a default fiscal offset exists.","solutions":["Call getFiscalDate with exactly two arguments, e.g. getFiscalDate(new Date(), 30).","Verify the second argument is a number of days, not a string.","Check for typos merging two calls onto one line."],"exampleFix":"// before\nvar fiscal = getFiscalDate(orderDate);\n// after\nvar fiscal = getFiscalDate(orderDate, 30);","handlingStrategy":"validation","validationCode":"var d = orderDate instanceof Date ? orderDate : new Date();\nvar days = isNaN(+offset) ? 0 : +offset;\nvar fiscal = getFiscalDate(d, days);","typeGuard":"function isDateArg(v){ return v instanceof Date && !isNaN(v.getTime()); }","tryCatchPattern":null,"preventionTips":["Pass exactly two arguments: a Date and a numeric day count.","Validate the offset variable before use.","Check the function signature in ScriptValuesAddedFunctions when in doubt."],"tags":["javascript","argument-count","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"}