Hitachi Vantara Pentaho Community Forums
Results 1 to 3 of 3

Thread: SetVariable in script value component

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default SetVariable in script value component


    I am having some struggles in understanding the behaviour of the method setVariable when used in Script Value component. Variable scopes are nicely described here
    but I have some problems when re-running the transformation where it seems that the variable is reused from the previous run. Here is the snippet from the component:

    var filenameList = getVariable("FILENAME_LIST","");
    // Add first filenam
         filenameList = inputFilename+ ";" +outputFilename;
    // Add additional filenames
         filenameList += "\n"+inputFilename+ ";" +outputFilename;
    writeToLog("FileList: "+filenameList);
    // Set variable up-to the root job

  2. #2
    Join Date
    Jun 2012


    You don't say so, but I guess you're running your transformation from spoon, yes?
    In that case you will notice that variables you set will persist until you restart spoon.
    Or you adjust the variable scope from "root" to "parent", so spoon's variable space isn't touched.
    So long, and thanks for all the fish.

  3. #3
    Join Date
    Apr 2008


    Looking at the code you are running, I see a giant warning: You CANNOT set and get variables within the same transformation.

    So if you have incoming data:

    and you run the above code, you will get odd results.

    What is your end-goal for this piece of work? We can make some suggestions on how to implement in PDI.

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.