DataWindow 'like' filter does not work if it is not placed last in the list of filters or within parenthesis

Symptom

DataWindow ‘like’ filter does not work if it is not placed last in the list of filters or within parenthesis. For example, the below script returns -1, which means the ‘like’ filter does not work.

dw_1.setfilter('  facility_name like "com%" and facility_id > 200 ')

Solution

This is old PB bug and can be resolved with either resolution of the below:

1. Put the ‘like’ filter in a parenthesis (recommended) like the below script:

dw_1.setfilter('  (facility_name like "com%" ) and facility_id > 200 ')

2. Place the like’ filter last in the list of filters like the below script:

dw_1.setfilter('   facility_id > 200 and facility_name like "com%"  ')