This topic is locked
[SOLVED]

 limit search values

10/4/2017 8:32:38 AM
PHPRunner General questions
K
keithh0427 author

I'm trying to limit one of the search fields to a specific value depending upon the user.
Within the "AfterTableInit" function, I have the following code:
$regionID = $_SESSION["regionID"];

$srchObj = SearchClause::getSearchObject("community"); // table is community
if ($_SESSION["regionAdmin"] == '0')

{

$query->addWhere("regionID = $regionID"); // this limits the filter panel to the user's regionID and is working

$srchObj->setFieldValue("regionID", $regionID ); // field name is regionID

} else {

$query->addWhere("regionID > 0 AND encounterID > 99");

}
But, the regionID drop[down continues to display all of the region possibilities instead of limiting it to the user's regionID.
According to the manual for v9.8, this code should work.

Sergey Kornilov admin 10/4/2017

Filter is based on data in the current table. Lookup wizards are based on data in lookup table meaning that you need to add similar code to lookup table AfterTableInit event.

K
keithh0427 author 10/4/2017



Filter is based on data in the current table. Lookup wizards are based on data in lookup table meaning that you need to add similar code to lookup table AfterTableInit event.


I removed the code from the community table and I have added the following to the region table "AfterTableInit":
$regionID = $_SESSION["regionID"];

$srchObj = SearchClause::getSearchObject("region");
if ($_SESSION["regionAdmin"] == '0')

{

$regionID = $_SESSION["regionID"];

$srchObj->setFieldValue("regionID", $regionID );

}
I also tried $srchObj->setSearchSQL("regionID", "regionID = $regionID");
Both of these worked to the extent that I can only use the $regionID in order to see the dependant dropdown.
The default option for the dropdown is the $regionID, but I still get all of the regions in the dropdown for the Search, Add and Edit pages.
Is there a way to remove all of the other regions and just see the $regionID in the dropdown?

K
keithh0427 author 10/4/2017

Just a followup.
I still need to see all regions for the $regionAdmin

K
keithh0427 author 10/4/2017

Solved the issue by using:
$query->replaceWhere( "regionID = $regionID" );
I do appreciate your quick response earlier.
Thank you.