{"record":{"id":"8689bcd0744f80ce","repo":"pentaho/pentaho-kettle","slug":"unknown-field-specified-to-replace-with-a-formula-result-8689bc","errorCode":null,"errorMessage":"Unknown field specified to replace with a formula result: [","messagePattern":"Unknown field specified to replace with a formula result: \\[","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/janino/Janino.java","lineNumber":83,"sourceCode":"\n    if ( first ) {\n      first = false;\n\n      data.outputRowMeta = getInputRowMeta().clone();\n      meta.getFields( getTransMeta().getBowl(), data.outputRowMeta, getStepname(), null, null, this, repository,\n        metaStore );\n\n      // Calculate replace indexes...\n      //\n      data.replaceIndex = new int[meta.getFormula().length];\n      data.returnType = new ValueMetaInterface[meta.getFormula().length];\n      for ( int i = 0; i < meta.getFormula().length; i++ ) {\n        JaninoMetaFunction fn = meta.getFormula()[i];\n        data.returnType[i] = ValueMetaFactory.createValueMeta( fn.getValueType() );\n        if ( !Utils.isEmpty( fn.getReplaceField() ) ) {\n          data.replaceIndex[i] = getInputRowMeta().indexOfValue( fn.getReplaceField() );\n          if ( data.replaceIndex[i] < 0 ) {\n            throw new KettleException( \"Unknown field specified to replace with a formula result: [\"\n              + fn.getReplaceField() + \"]\" );\n          }\n        } else {\n          data.replaceIndex[i] = -1;\n        }\n      }\n    }\n\n    if ( log.isRowLevel() ) {\n      logRowlevel( \"Read row #\" + getLinesRead() + \" : \" + getInputRowMeta().getString( r ) );\n    }\n\n    try {\n      Object[] outputRowData = calcFields( getInputRowMeta(), r );\n      putRow( data.outputRowMeta, outputRowData ); // copy row to possible alternate rowset(s).\n      if ( log.isRowLevel() ) {\n        logRowlevel( \"Wrote row #\" + getLinesWritten() + \" : \" + data.outputRowMeta.getString( outputRowData ) );\n      }","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/janino/Janino.java#L65-L101","documentation":"Thrown by the Janino (Formula) step's processRow during initialization when a formula is configured with a 'Replace value' field that does not exist in the incoming row. The step cannot locate the column whose value should be replaced by the formula result.","triggerScenarios":"A JaninoMetaFunction has a non-empty replaceField, but getInputRowMeta().indexOfValue(replaceField) returns -1 — the upstream row layout differs from what the step was configured against.","commonSituations":"Renaming or removing an upstream field after configuring the formula; inserting a Select Values step that drops the field; the transformation runs with different incoming field order/case sensitivity.","solutions":["Open the Formula step and correct the 'Replace value' field name to match an incoming field exactly (case-sensitive).","Clear the 'Replace value' box if you want a new field instead of replacing one.","Re-run 'Get Fields' / re-verify hop metadata after changing upstream steps.","Check any upstream Select/Filter steps that may remove or rename the field."],"exampleFix":"// before\nfn.setReplaceField(\"cust_name\"); // field was renamed upstream\n// after\nfn.setReplaceField(\"customer_name\");","handlingStrategy":"validation","validationCode":"// Before running, confirm the replace field exists in the stream\nString[] fields = inputRowMeta.getFieldNames();\nboolean found = Arrays.stream(fields).anyMatch(f -> f.equals(fn.getReplaceField()));\nif (fn.getReplaceField() != null && !found) {\n  throw new IllegalStateException(\"Replace field not in stream: \" + fn.getReplaceField());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the dialog's field dropdown rather than typing names.","Re-verify the transformation after any upstream field changes.","Keep a Select Values step to pin down field names/order before the formula."],"tags":["kettle","formula","field-mapping"],"backgroundTag":"resource-not-found","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"}