pentaho - Error Cannot call method "substring" of null in Script Values - PDI -
i'm using pdi spoon , wrote script in script values values, check , transform:
var cte; cte = gera_cte (ctrc.getstring(), numero_cte.getstring()); function gera_cte (arg1, arg2) { if (arg2 == 0) { return arg1.substring(3,9); } else { return arg2.substring(4,10); } }
but when script read last record, happen:
2016/02/05 17:28:40 - gera num cte.0 - error (version 5.0.1-stable, build 1 2013-11-15_16-08-58 buildguy) : erro inesperado 2016/02/05 17:28:40 - gera num cte.0 - error (version 5.0.1-stable, build 1 2013-11-15_16-08-58 buildguy) : org.pentaho.di.core.exception.kettlevalueexception: 2016/02/05 17:28:40 - gera num cte.0 - javascript error: 2016/02/05 17:28:40 - gera num cte.0 - typeerror: cannot call method "substring" of null (script#12) 2016/02/05 17:28:40 - gera num cte.0 - 2016/02/05 17:28:40 - gera num cte.0 - @ org.pentaho.di.trans.steps.scriptvalues_mod.scriptvaluesmod.addvalues(scriptvaluesmod.java:457) 2016/02/05 17:28:40 - gera num cte.0 - @ org.pentaho.di.trans.steps.scriptvalues_mod.scriptvaluesmod.processrow(scriptvaluesmod.java:692) 2016/02/05 17:28:40 - gera num cte.0 - @ org.pentaho.di.trans.step.runthread.run(runthread.java:60) 2016/02/05 17:28:40 - gera num cte.0 - @ java.lang.thread.run(unknown source) 2016/02/05 17:28:40 - gera num cte.0 - caused by: org.mozilla.javascript.ecmaerror: typeerror: cannot call method "substring" of null (script#12)
how can solve issue, because in end of file?
you have line in file, makes run null
values.
you should filter out illegal rows before reach java script step, or check input values in function like:
function gera_cte (arg1, arg2) { if (arg1 == null) { return arg1; } if (arg2 == 0) { return arg1.substring(3,9); } else { return arg2.substring(4,10); } }
or setting trans_status = skip_transformation;
when arguments null.
Comments
Post a Comment