Making a query filter "stick" with a query object

I want the custtable to only show customers in Arizona, so I added this on the CustTable_ds.init method:

custTable_ds.query().dataSourceTable(tableNum(custTable)).addRange(fieldNum(CustTable, State)).value(‘AZ’);

This works initially, but if the user presses Ctrl+G, they can just clear out that filter. How can I make it “stick” or permanent? This seems like it should be really easy, but I’m just missing something.

As you have written your code in init method - which will be executed during the initialization of CustTable data when the form is opened, the furthur changes may have not get effected.

It is better to write your code in executeQuery method which will be executed for every change in the query…

I tried putting the same line of code before and after the super and it doesn’t “stick”. If I go to the filter and type “IN” or some other state, it will show other states.

Are you assigning the query somehow differently?

Try by changing your range status - keep it as Locked…