Conditional Lookup Selecting Issue

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

Conditional Lookup Selecting Issue

Post by ebinnasir »

Hello,

Hope all are fine.

I am facing issue to set a condition on lookup selecting. Lookup Select field is in detail table and filter field is in master table. In my case if parent field value is finished_fabric then value will get from delstore_summery table otherwise value will get from gray_requisition_details table. I placed the below code on Table Specific-> Lookup_Selecting:

if (($this->isGridAdd()) && ($fld->Name == "grd_batch_no")) {

    if (Container("deliveryhub")->delivery_type->FormValue == "finished_fabric") {

        $fld->Lookup->UseLookupCache = false; 
        $fld->Lookup->UserSelect = "SELECT grd_batch_no AS lf, grd_batch_no AS df, 'Finished Fabric' AS pf FROM delstore_summery"; 
    }
    else {
            $fld->Lookup->UseLookupCache = false; 
        $fld->Lookup->UserSelect = "SELECT grd_batch_no AS lf, grd_batch_no AS df, 'Grey Fabric' AS lf FROM gray_requisition_details";

    }
}

As I am setting this lookup for ADD form, so there are possibilities of not available field value initially. But after choosing parent field value this lookup also not executing expected query. All time lookup is giving option from second part (SELECT grd_batch_no AS lf, grd_batch_no AS df, 'Grey Fabric' AS lf FROM gray_requisition_details";);

I think there are problems to get value from Container("deliveryhub")->delivery_type->FormValue. Can experts suggest me to solve this issue?

Thanks in Advance.


arbei
User
Posts: 9384

Post by arbei »

ebinnasir wrote:

As I am setting this lookup for ADD form, so there are possibilities of not available field value initially. But after choosing parent field value this lookup also not executing expected query.

Note that Lookup_Selecting is server event, it is fired when the page is loaded (before outputting to browser). When the user choose a parent field value on the client side, it will not fired. And there is no Container("deliveryhub")->delivery_type->FormValue at all.

However, if you use Dynamic Selection List, you may read Lookup_Selecting -> Example 6.


Post Reply