Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: Dtermine length of a string and set another field

  1. #1

    Default Dtermine length of a string and set another field

    I want to determine the length of the input field and then set another field based on the length

    I got help for determining the length as below:

    var field1 = value.getString();
    var len = field1.length();

    if value is an input field.


    but now I wanna add new field "NewField" to every row
    If len<2, then NewField=N,
    else NewField=Y

    How do go about this? How to add new field and set the corresponding value based on length of a field?

    I'm sorry if it's a newbie question ...I'm new to Kettle and javascript both

  2. #2
    Join Date
    May 2006


    Have a look under the samples directory in your installation. Look for filenames with "JavaScript" in the name, I'm pretty sure there's one adding a field to the input.


  3. #3



    I had a look at all the transformations under samples. But I couldn't find one which adds a new field and assigns a value to it.

    For my case, can you please paste the piece of code?


    Now how do I pass the value of variable 'lengthind' through a new field 'Newfield?

    I tried


    But it didn't work. I'm sure it's a 2 line code, but I am not aware of it. Can you paste it for me?

  4. #4


    Look at the bottom of the MOdified Java Script Value step (when you are editing it)

    You can add any of the fields declared as VAR in the script to this list. This would be the new fields that go down the data stream....

    (You can press GET VARIABLES button also, and it will attempt the populate the fields for you. )

    Make sure the data type is filled in and correct....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.