Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: set javascript variable with a compound statement including if

  1. #1
    Join Date
    Nov 2014
    Posts
    1

    Default set javascript variable with a compound statement including if

    m using Pentaho to move some csv data into xml data and I need a little javascript help.
    im setting up groups of elements that will get compiled under larger elements later, one element has name information, but I want to leave out the middle name element if the csv file is null in that field.
    var ind ='<ind><name><last>'+LNAME+'</last><first>'+FNAME+'</first>'+if(ISUBJ_MNAME==null){'<middle>'+ISUBJ_MNAME+'</middle>';}+'</name> </ind>'is there something glaringly wrong with this? I feel like it should work, but this is literally my first exposure to javascript.



    Thank you

  2. #2
    Join Date
    May 2012
    Posts
    110

    Default

    I am not an expert, but this works:

    var ind;

    if(ISUBJ_MNAME==null)
    {var ind ='<ind><name><last>'+LNAME+'</last><first>'+FNAME+ '</first>'+'<middle>'+ISUBJ_MNAME+'</middle>'+'</name> </ind>';}
    else {var ind ='<ind><name><last>'+LNAME+'</last><first>'+FNAME+'</first>'+'</name> </ind>';}
    Regards Vince

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.