Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: Javascript

  1. #1

    Default Javascript

    Hi,

    I was trying to move a field value which is not blank to a new field. But it showing error like TypeError: Cannot call method "match" of null (script#3)
    I would appreciate if u provide the right code for this.

    var
    str= UnitNumber.getString();

    var
    str1= null;

    if
    (str.match(str1))
    {
    unitout=str.
    substr(0,6);
    }

    else
    {
    unitout=
    ' ';

    }


    The file is like below:

    UnitNumber Expected o/p

    58 Unit : 58

    89 Unit : 89
    54 Unit : 54

    Here the expected o/p should contain the prefix Unit: But i havent added it in the code.
    suggest that also how to include in the coding part.

    Thanks in advance
    senthil

  2. #2

    Default

    I got the right code for my query.

    var
    str1= UnitNumber.getString()
    if
    (str1 != null)
    {
    NUMOUT=str1.substr(0,6);
    }
    else
    {
    NUMOUT=' ';

    }

    But here i need to add a prefix "Unit: "as i mentioned earlier. How to add it in the coding part. can anyone suggest.

    Thanks in advance.

  3. #3
    Join Date
    May 2006
    Posts
    4,882

    Default

    Don't double post... it just doesn't help

  4. #4

    Default

    sorry its a typo.

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.