I set a filter and the field lenght is shorter than a string

lagiac83
Member Posts: 29
An error happens when I run this code:
String := '';
Job.SETRANGE("Guest No.",Contact."No.");
IF Job.FIND('-') THEN BEGIN
REPEAT
String := String + Job."No." + '|';
UNTIL Job.NEXT = 0;
String := PADSTR(String,STRLEN(String)-1);
END;
Quantity := 0;
JobBudgetEntry.SETCURRENTKEY("Job No.",Date,"Phase Code","Task Code","Step Code","Resource Group No.");
JobBudgetEntry.SETFILTER("Job No.",String); // HERE THERE IS THE ERROR
My string sometimes can be longer than 20 character (Job No. is a Code[20]).
Why when I run the table and I press F7 (Field Filter) and I insert a text of more 20 characters like this:
PDA007|PDA008|PDA009|PDA010|PDA120 the error doesn't happen?
What can I do?
With Regards,
Giacchetto Yuri
String := '';
Job.SETRANGE("Guest No.",Contact."No.");
IF Job.FIND('-') THEN BEGIN
REPEAT
String := String + Job."No." + '|';
UNTIL Job.NEXT = 0;
String := PADSTR(String,STRLEN(String)-1);
END;
Quantity := 0;
JobBudgetEntry.SETCURRENTKEY("Job No.",Date,"Phase Code","Task Code","Step Code","Resource Group No.");
JobBudgetEntry.SETFILTER("Job No.",String); // HERE THERE IS THE ERROR
My string sometimes can be longer than 20 character (Job No. is a Code[20]).
Why when I run the table and I press F7 (Field Filter) and I insert a text of more 20 characters like this:
PDA007|PDA008|PDA009|PDA010|PDA120 the error doesn't happen?
What can I do?
With Regards,
Giacchetto Yuri
0
Comments
-
I forget to say that I'm working in Navision 3.700
-
Because your code is trying to search for that whole string as Job No.
the right way to filter is
JobBudgetEntry.setfilter(Job No.,'%1|%2|%3',str1,str2,str3);
but if you do not know the count of jobs you going to have then best if to put the jobbudgetentry filter inside the repeat loop.
Jobbudgetentry.setfilter(Job No, Job.Jobno);
cheers0 -
1024 ??
I would not recommend this.
The max filter Length on a field as text is 720 CHAR.
U will soon reach the max length. I recommend to make a better function that builds a filter string like PDA007..PDA010|PDA125| PDA128.. PDA130
This also can reach the limit.. but will delay it.
MARK(TRUE)/MARKEDONLY(TRUE)?? Bad for the performance. U can`t set a key on it.0 -
@Scheppie
That's not completely true. The length of the filter is not the only limitation, the number of elements within the filter also play a role on how long the filter string can be.
These examples are just to illustrate my point
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1
This may give an error because there are too many elements
12345|12345|12345|12345|12345|12345|12345|12345|12345|12345|
12345|12345|12345|12345|12345
A longer string but it has less elementsThis isn't a signature, I type this at the bottom of every message0 -
SteveO wrote:[...] the number of elements within the filter also play a role on how long the filter string can be.
[...]
Have you tested this?
How many elements are possible?Timo Lässer
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions