Page 1 of 1

How to conditionally override Requires Search setting

Posted: Mon Jun 05, 2023 8:39 pm
by philmills

My table has Requires Search enabled in Table Options > List Page
I would like to override this based on condition such as

if (CurrentUserLevel()=='1') {
	//don't require search
}

Whats the syntax for that and where should it be placed?


Re: How to conditionally override Requires Search setting

Posted: Tue Jun 06, 2023 8:48 am
by mobhar

You may actually generate the script files twice. First for the Requires search option enabled, then backup the models/*List.php file to another place. After that, for the second times, make that option disabled, regenerating ALL the script files again.

You may then compare both models/*List.php file by using Winmerge application... so you will be able to know which code that will make that option enabled.


Re: How to conditionally override Requires Search setting

Posted: Tue Jun 06, 2023 9:44 am
by arbei

You better reverse it, that is, do not enable Requires Search. Then use Recordset_SearchValidated to validate the search values. If requiring search but there is no search values, you may add your own and set a warning message.


Re: How to conditionally override Requires Search setting

Posted: Wed Jun 07, 2023 4:33 pm
by philmills

I can't reverse it as I'm not in a position to regenerate all the code. I'm part way through upgrading from 2022 to 2023. It's a very large project.
I just need a temporary fix


Re: How to conditionally override Requires Search setting

Posted: Wed Jun 07, 2023 6:38 pm
by arbei

Then you can only manually customize the generated scripts yourself.


Re: How to conditionally override Requires Search setting

Posted: Thu Jun 08, 2023 8:57 am
by mobhar

As I mentioned before, after comparing the two versions of the related generated script files, then you will know the code that will make Requires search logic. You may use that code in Recordset_Selecting server event afterwards.