Modified method for ControlButton

Hi,

I am facing the situation where I have one form which is developed for listing contracts. At header of that form is Control Button for displaying only active contracts and not display expired one.

For now situation is next: always when this form is opened it show all contracts regardless is it active or expired.

For this control button there is this modify method:

public boolean modified()
        {
            boolean ret;
            utcdatetime utcMaxDate, utcMinDate;

            utcMinDate = DateTimeUtil::minValue();
            utcMaxDate = DateTimeUtil::maxValue();
                
            ret = super();

            if (ShowAll.value() == true)
            {
                Contract_ds.validTimeStateAutoQuery(ValidTimeStateAutoQuery::DateRange);
                Contract_ds.query().validTimeStateDateTimeRange(utcMinDate, utcMaxDate);
            }
            else
            {
                Contract_ds.validTimeStateAutoQuery(ValidTimeStateAutoQuery::AsOfDate);
                Contract_ds.query().resetValidTimeStateQueryType();
            }

            Contract_ds.executeQuery();
        
            return ret;
        }

What should I do to show only active ones until Display all contracts are checked ?

I think it should work out by default, therefore I winder why it doesn’t work in your case.

But if you can’t figure it out, you can extract the code from modified() to a separate method and call the logic not only when the filter is modified, but also when you initialize the form.

It’s not working by default. The need is to show up all contracts when checkbox is checked on Display All Contracts. This is not working unless I put Valid Time State Auto Query on DateRange instead AsOfDate.

After that on init it shows always all contract, but need is to show only active ones until ControlButton is checked.

Yes, that’s correct. I thought that your statement “always when this form is opened it show all contracts regardless is it active or expired” is a description of the behavior you see (and don’t want). If you mean that that’s what you want to implement, then follow my suggested solution.

Probably I’m doing something wrong. Simply doesn’t work.

Working. Thanks a lot.