US and Worldwide: +1 (866) 660-7555
Results 1 to 2 of 2

Thread: Using Parameters in a Javascript step

Hybrid View

  1. #1

    Default Using Parameters in a Javascript step

    To use a Parameter inside a JavaScript step using PDI you do the following

    Step 1:
    Go into the Transformation's properties->Parameter tab
    Create a variable, for instance RUNDATE and set a default value, say 07.15.2009.
    Click OK.

    Step 2:
    In the javascript step in PDI, if you wanted to feed that variable in as a Date you would use the following line

    StopDate = str2date(getVariable("RUNDATE", "07.01.2009"),"MM.dd.yyyy");
    Last edited by Smoodo; 07-16-2009 at 02:21 PM.

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

    Default

    Code:
    var runDate = getVariable("RUNDATE", "?");
    From the sample help code:

    Code:
    // Retrieves the value of a given Kettle/Pentaho Variable
    // 
    // Usage:
    // getVariable(var, var);
    // 1: String - The name of the variable to retrieve.
    // 2: String - The default if the variable doesn't exist.
    //
    // 2007-07-27
    //
    var strVarName="getVariableTest";
    var strVarValue="123456";
    Alert(getVariable(strVarName, ""));
    setVariable(strVarName,strVarValue, "r");
    Alert(getVariable(strVarName, ""));
    strVarValue="654321";
    setVariable(strVarName,strVarValue, "r");
    Alert(getVariable(strVarName, ""));
    Matt Casters, Chief Data Integration
    Pentaho, Open Source Business Intelligence
    http://www.pentaho.org -- mcasters@pentaho.org

    Author of the book Pentaho Kettle Solutions by Wiley. Also available as e-Book and on the Kindle reading applications (iPhone, iPad, Android, Kindle devices, ...)

    Join us on IRC server Freenode.net, channel ##pentaho

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •