Detail Table data filter

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
ebinnasir
User
Posts: 103

Detail Table data filter

Post by ebinnasir »

Hello,

I am working on a master/details table view page. I want to show detail table data based on userlevel. I write the below code on Recordset_Selecting of Server Event:

if (CurrentUserLevel() == 6 || 7) {
ew_AddFilter($filter, "process_type = After-Treatment || Heatset"); 
} else if ((CurrentUserLevel() == 4 || 5) {
ew_AddFilter($filter, "process_type = Pre-Treatment || Dye"); 
}

after generating code, showing error message: Call to undefined function PHPMaker2024\project2024\ew_AddFilter()

Can experts suggest me what is the right code for this filter?


mobhar
User
Posts: 11841

Post by mobhar »

You should use AddFilter instead of ew_AddFilter in v2024.


arbei
User
Posts: 9603

Post by arbei »

ebinnasir wrote:

if (CurrentUserLevel() == 6 || 7) {

Wrong syntax. Similarly for other lines.


ebinnasir
User
Posts: 103

Post by ebinnasir »

Hello,

I made the suggested changes but still getting error message. Updated code looks like below:

function Recordset_Selecting(&$filter)
{
if (CurrentUserLevel() == 7) {
 AddFilter($filter, "process_type = After-Treatment"); // adjust with your own filter criteria
 }
}

An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'After' in 'where clause'.


arbei
User
Posts: 9603

Post by arbei »

ebinnasir wrote:

An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'After' in 'where clause'.

Wrong syntax: (string should be single quoted in SQL)

AddFilter($filter, "process_type = After-Treatment");


mobhar
User
Posts: 11841

Post by mobhar »

Try:

AddFilter($filter, "process_type = 'After-Treatment'");

ebinnasir
User
Posts: 103

Post by ebinnasir »

This works. Thanks


Post Reply