Main Lookup/Link Lookup and specifying a List View

Posted by Meryk on 05-Mar-2015 10:28

Hi,

I have two objects A and B with relationship one to many, so one A can have many B. Also object B has a type (which is just a field), lets say type can be type1 or type2.

On the edit page of object B, the field of the related A is a selector, and when clicked  the B selector page opens.

I have ticked the options "Main Lookup" and "Link Lookup" in the properties of the field. And this is working fine : when I open edit page of a record of A, and click the B selector field, it is showing only related records (Bs) to the current A in the selector page that opens.

Now I need to do some more filtering on this page , using that type I mentioned before. So when "someCondition", only display current related Bs of type1 and when "someOtherCondition", only display current related Bs of type2.

To make it simple, once options "Main lookup"  and "link lookup" are checked, if you go to that edit page of object B, and set the List view of the lookup (of object A) to any other view, it won't take it. It will always display the current related records.

Do you have any ideas how this can be resolved please?

Thank you

Meryem

All Replies

Posted by Godfrey Sorita on 05-Mar-2015 12:44

Hi Meryem,

This is a known limitation of link lookup fields. The view filter is not taking effect because the main lookup field is the one defining the filter. Similar to Selector Pages, only 1 source of filter can be active at a time.

A workaround for this is to merge the value of lookup and type into 1 field using triggers. Then use rbf_setLookupFilter() to filter B object records.


Regards,
Godfrey

Posted by Meryk on 06-Mar-2015 04:00

Hi Godfrey,

Thank you for the reply. Yes I have tried using rbf_setLookupFilter() twice, for both the lookup field and the type but only the last one is activated.

For the workaround you are suggesting, I created A Formula field containing filterVal1_filterVal2, and I am using it with setLookupFilter. And it is still not working.

Do you know if there is a restriction with formula fields used in rbf_setLookupFilter ?

Should I try the same thing with  just a text field for e.g ..?

Thank you

Meryem

Posted by Meryk on 06-Mar-2015 04:15

Hi Again,

I just tried the same thing using a text field, which I fill using a trigger. And now it is working fine with the setLokkupFilter().

Thank you :)

Meryem

This thread is closed