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 ? 

Related
Recommended