Lookup: Set Value for Parent/Filter #1

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
mpol_ch
User
Posts: 877
Location: Switzerland

Lookup: Set Value for Parent/Filter #1

Post by mpol_ch »

Hi

How can set the value for Parent field ad Filter filed for the following lookup table?

Table name: personen
Link field: Id
Parent/Filter #1
Parent field: knr
Filter filed: Ref

I want to do the following check
if CurrentPageId() == "add" then Ref==0 (There will be no selection...)
If CurrentPageId()=="edit" then Ref== $this->knr->CurrentValue

I do not find a suited example in the documentation.

thanks
mpol_ch


sangnandar
User
Posts: 980

Post by sangnandar »

Looks like you need Lookup_Selecting().
Check the help file, it's there.


mpol_ch
User
Posts: 877
Location: Switzerland

Post by mpol_ch »

Hi,
yes I am looking the Lookup_Selecting().
But how can I define the value of Filter and Parent for CurrentPageId()="add" or CurrentPageId()="edit"?

thanks
mpol_ch


mobhar
User
Posts: 11709

Post by mobhar »

Try:

if ($fld->FldName == "Id" && CurrentPageID()=="add")
ew_AddFilter($filter, "Ref = 0"); // Assume the field is of numeric type

if ($fld->FldName == "Id" && CurrentPageID()=="edit")
ew_AddFilter($filter, "Ref = " . CurrentPage()->knr->CurrentValue); // Assume the field is of numeric type


mpol_ch
User
Posts: 877
Location: Switzerland

Post by mpol_ch »

Hi mobhar,

thanks.
I am adding with "+" new entries into detail table from master one.
Now I can only add a record with + into detail but not mores.
The adding does not work for add and edit.

Do you know why?

thanks
mpol_ch


mobhar
User
Posts: 11709

Post by mobhar »

mpol_ch wrote:
Now I can only add a record with + into detail but not mores.

Please explain it in more detail, what does it mean?

mpol_ch wrote:
The adding does not work for add and edit.

Please explain it in more detail, what does it mean?


mpol_ch
User
Posts: 877
Location: Switzerland

Post by mpol_ch »

Hi mobhar,

I am having with "allow add" with + button to add a record (contact person) for this lookup field (kperson).
When I use your code then I cann add onfly olny one record on fly (into detail table contact person).
For example when try to add on fly a second record into contact person with + then this is not added into detail table and not shown in lookup field too..

I hope it clearer now.

Thanks
mpol_ch


mobhar
User
Posts: 11709

Post by mobhar »

mpol_ch wrote:
this is not added into detail table and not shown in lookup field too..

Probably because it is related to your filter criteria for of Lookup_Selecting server event. Check to your table, does it contain the second record in there?

In addition, enable Debug mode, and check whether any error message returned?


Post Reply