Hitachi Vantara Pentaho Community Forums
Results 1 to 6 of 6

Thread: How does the Evaluating Javascript job entry

  1. #1

    Default How does the Evaluating Javascript job entry

    Dear,

    Would it be possible to see an easy example of the functioning of the Evaluating Javascript job entry ?

    I would like to test the value of a field to run an sub-job or an other...

    Is it possible to use data from the previous transformation as variable or are only available the variables given in the doc ?

    I don't achieve to do work it.

    Thanks a lot for your answer.

    Regards
    Gambi

  2. #2

    Post

    Hi,

    See the attached sample..It will help you

    Rgds
    Attached Files Attached Files

  3. #3

    Default

    Thanks for your example Shassan.

    However I would like to evaluate several lines and I don't achieve to do work it.

    I've tried this, but it doesn't work :
    for(var i;i<lines_read;i++)
    var test=rows[i].getInteger("data",-1);
    test = "toto";

    I would like to distribute each line according to their value

    Besides, could you please explain me what means the parameters of the getInteger... var test=rows[0].getInteger("data",-1);

    Thanks for your help.
    Regards

    Gambi
    Last edited by Gambi; 05-23-2007 at 10:42 AM.

  4. #4

    Default

    Hi Gambi,

    The second argument (ie -1) is the default value ( if the field value does not have the correct numeric format, or if the specified name is empty or null).

    In fact rows[0] is the first row from the previous entry,rows[1] is the second one,...
    The evaluation is done once, it can loop (if i well understand).

    If you want to test for each line, use another job and check "Copy previous to args" and "Execute fo every input row".

    The second job will contain the evaluation entry and will receive one row at a time. (row[0))

    Samatar

  5. #5

    Default

    Hi Samatar,

    Your idea to loop is good. I tried it yersterday.
    But strangely, it doesn't work.

    I checked, in the sub-job entry the 2 options : "Copy previous to args" and "Execute fo every input row", and the evaluation doesn't work.
    So I unchecked the first one and filled the field under it with the name of my test field (data).

    The evaluation works, but the value of the field isn't keep and nothing is written in my file_out (I put a transformation which writes in a file the value of the field. To get the field I use a system info step.)

    I put here my job. I may forget something... My input file is like this :
    data
    1
    6
    1
    2
    0
    7
    5
    Thanks one more time for your help.

    regards
    Gambi
    Attached Files Attached Files

  6. #6

    Thumbs up

    Well, it works !

    I only put an first transformation in my sub-job to get the field in all the sub-job.

    It seems that without this the information isn't pass in the other transformation of the sub-job.

    I don't know why ?

    Besides, to evaluate, I've to uncheck the option "Copy previous to args" and fill the option below, as explain in my previous post.
    It's strange...

    Thanks for your help
    Regards
    Gambi

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.