CONDITIONAL LOOKUP

My need is to check the value in another table to determine if the user is allowed to lookup the associated table from any form.

So far, my SO Line form does not allow any lookup at all, here is my code in Table 36:

Currency Code - OnLookup()

UserSetup.GET(USERID);

IF UserSetup.“Team Filter” = ‘’ THEN BEGIN //Any characters in this field will stop any lookup/view

LCurr.SETRANGE(“Allow Selection in NAV” , TRUE);

IF lcurr.FINDSET THEN BEGIN

LFormCurrencies.SETTABLEVIEW(LCurr);

LFormCurrencies.SETRECORD(LCurr);

LFormCurrencies.LOOKUPMODE(TRUE);

END;

END;

Any ideas please?

Found the answer.

I did not need to populate the field but now that I have added that part, it all works correctly:

Here is the revised code:

UserSetup.GET(USERID);

IF UserSetup.“Team Filter” = ‘’ THEN BEGIN

LCurr.SETRANGE(“Allow Selection in NAV” , TRUE);

IF LCurr.FINDSET THEN BEGIN

LFormCurrencies.SETTABLEVIEW(LCurr);

LFormCurrencies.SETRECORD(LCurr);

LFormCurrencies.LOOKUPMODE(TRUE);

IF LFormCurrencies.RUNMODAL = ACTION::LookupOK THEN BEGIN

LFormCurrencies.GETRECORD(LCurr);

“Currency Code” := LCurr.Code;

END;

CLEAR(LFormCurrencies);

END;

END;