Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: Using Parameters in a Javascript step

  1. #1
    Join Date
    Apr 2008
    Posts
    146

    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,729

    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, ""));

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
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

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