I apologize in advance - I am a newbie programmer in NAV.
I want to filter the location codes based on the sales order number (we have 4 different number systems). I have searched this site and my C-Side manuals and have tried different things, but with no success. The goal is to:
When a user clicks on the Lookup button on the Location Code:
IF Sales Number starts with SO- THEN
Location Code can be 'DC' or 'Corp'
Else If Sales Number starts with TS- THEN
Location Code can be 'TS-*' (TS stands for tradeshows and we have a specific location for each tradeshow)
Else
Allow all Location values
In the Sales Header, Location Code OnLookup I tried:
IF STRPOS("No.", 'TS-') = 1 THEN
SETFILTER("Location Code", 'TS-'+'*');
What happens is the filter is set to the Sales Header card and not the actual Location Form. Looking in some other threads, this defintiely does not seem to be correct way to do this. Can anyone point me in the right direction?
0
Comments
Create a local variable, Loc type record Location.
Then have the code to conditionally the the filter on the Loc table e.g.
Loc.SETFILTER(code,'=%1|%2','DC','Corp');
then the form:
form.runmodal(0,Loc);
On Location Code field OnLookUp
OrderNo:=FORMAT("No.");
OrderStartWith:=COPYSTR(OrderNo,1,3);
IF OrderStartWith='SO-' THEN BEGIN
Locs.SETFilter(Locs.Code,'%1|%2','DC','Corp');
IF Locs.FINDFIRST THEN BEGIN
IF FORM.RUNMODAL(15,Locs) =ACTION::LookupOK THEN
"Location Code":=Locs.Code;
END;
END;
Note: OrderNo and OrderStartWith are text Variable Locs is record type variable for Location
Ritesh K Singh
I think this will help you.............
Put this CAL Code just after On Location Code field OnLookUp trigger
IF COPYSTR("No.",1,3);='SO-' THEN
BEGIN
Locs.RESET;
Locs.SETFilter(Locs.Code,'%1|%2','DC','Corp');
IF Locs.FIND(‘-‘) THEN
BEGIN
IF FORM.RUNMODAL(0,Locs) =ACTION::LookupOK THEN
Validate("Location Code",Locs.Code)
END;
END
ELSE
BEGIN
IF COPYSTR("No.",1,3);='TS-' THEN
BEGIN
Locs.RESET;
Locs.SETFilter(Locs.Code,'TS-'+'*');
IF Locs.FIND(‘-‘) THEN
BEGIN
IF FORM.RUNMODAL(0,Locs) =ACTION::LookupOK THEN
Validate("Location Code",Locs.Code)
END;
END;
END;
Note :- Locs refers Location Table