Hitachi Vantara Pentaho Community Forums
Results 1 to 3 of 3

Thread: Create a new field dynamically

  1. #1
    Join Date
    Mar 2011
    Posts
    11

    Question Create a new field dynamically

    Hi
    I am using a javascript to read a .properties file that contains 3 fieldnames.
    Two of these fields already exist and the third is new field.
    Some calculation is performed on the existing fields and the result is to be stored in a new column.
    I am able to achieve this but, am not able to name the newfield with the name given in the properties file.

    This is my code:
    java;
    var p;

    if (p==null)
    {
    p = new java.util.Properties();
    var fis = new java.io.FileInputStream("D:/Pentaho/DataCollector/arg.properties");
    p.load(fis);
    fis.close();
    }

    var fieldname = p.getProperty("FIELD1");
    var fieldname2 = p.getProperty("FIELD2");
    var newfield = p.getProperty("NEWFLD");

    if (fieldname=="Values")
    var newVal = Values.getInteger();

    if (fieldname2=="Values2")
    var newVal1 = Values2.getInteger();

    var val = newVal * newVal1;

    var Field = Values.Clone();
    Field.setValue(val);
    row.addValue(Field);
    //Field.setName(newfield); //This doesn't work even in compatibility mode
    .......................

    Here I need to name the column "Field" as the name stored in the variable "newfield"
    Any ideas??

    Thanks in advance
    Pranjala

  2. #2
    Join Date
    Nov 1999
    Posts
    9,729

    Default

    You need to de-normalize the data using a step with a similar name.

  3. #3
    Join Date
    Mar 2011
    Posts
    11

    Default

    Thanks for the reply.

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.