Dynamically Filter Location Code based on Sales Order Number
ehartel
Member Posts: 4
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?
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
-
You need to set the filter on the location table.
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);0 -
Try this
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 LocationThanks,
Ritesh K Singh0 -
HI ehartel ,
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 TableNow or Never0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
