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

lagiac83lagiac83 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

Comments

  • lagiac83lagiac83 Member Posts: 29
    I forget to say that I'm working in Navision 3.70
  • bobnavisionbobnavision Member Posts: 159
    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);

    cheers
  • scheppiescheppie Member Posts: 2
    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.
  • SteveOSteveO Member Posts: 164
    @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 elements
    This isn't a signature, I type this at the bottom of every message
  • Timo_LässerTimo_Lässer Member Posts: 481
    SteveO wrote:
    [...] the number of elements within the filter also play a role on how long the filter string can be.
    [...]
    :shock: :shock: :shock:

    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]
Sign In or Register to comment.