tfilterrow Error filtering column data

One Star

tfilterrow Error filtering column data

Hi Guys,
Good Day! 
I'm trying to work on a project where I need to filter a row with some string on a specific column like "Not". I used the advance mode of the tfilterrow and define the condition: 
input_row.ColumnName.indexOf("Not") != -1 I also tried input_row.ColumnName.contains("Not") 
and it seems to filter out the row with the string on the column on it but it also filter out some rows that has no "Not" on that column.
I figure it out using the rejects output of the tfilterRow because I include the error message and some rows is an error because of the advance condition that I set up.
Is there any more accurate way to filter it out? 
Thanks In Advance
Regards
John 
Four Stars

Re: tfilterrow Error filtering column data

Is it possible that  input_row.ColumnName contains nullvalues sometimes ?
One Star

Re: tfilterrow Error filtering column data

 Hi djdeejay,
Yes it is possible ! 
Regards
John
Four Stars

Re: tfilterrow Error filtering column data

in this case input_row.ColumnName.contains("Not") will throw a null pointer exception, as there is no object for which the method contains() can be called.
You Need to ensure you have an object first, you might try this :  
(input_row.ColumnName==null?new String(""):input_row.ColumnName).contains("Not")

you can replace new String("") with new String("Not") if you want to have Default NOT in the NULL case
HTH
PS: if your can ask for equality then it is best practise to use:  "Not".equals(input_row.ColumnName) which reduces to "Not".equals(null) and results into false then