In this case you are using the wrong filter.
The filter your using means set a filter on the "Salesperson Code" from '1' until '2'.
And because the "Salesperson Code"-field is datatype CODE everything starting with '1' is also in the filter.
The filter you can use is:
Customer.SETFILTER( "Salesperson Code",'%1|%2','1','2');
You can construct filters using the following operators.
Operator Description
.. Range
& And
| Or
< Less than
<= Less than or equal to
> Greater than
>= Greater than or equal to
<> Different from
* Forms a part of value
@ Case-insensitive
Set a filter on the customer-tabel ( Customer.SETFILTER)
on the field "Salesperson Code" ( "Salesperson Code" )
Use as filtervalue parameter 1 OR parameter 2 ( ,'%1|%2' )
use for the first parameter the value '1' ( ,'1' )
use for the second parameter the value '8' ( ,'8')
AK - what you wrote is making sense to me, 1,11, 2 ,22 etc. but for the life of me I cannot see a way of doing it other than to select it based on 1 - 8 and then exclude 11?
Just wanted to say thanks everyone - my logic was right but I was trying to put the > or <> in the wrong place rather than setting parameters! As I said very new to this but finding the forums really helpful for learning
Answers
Your code doesn't work because you filter from 1 to 2, and with the sorting of your DB the salesperson records look like this:
The filter your using means set a filter on the "Salesperson Code" from '1' until '2'.
And because the "Salesperson Code"-field is datatype CODE everything starting with '1' is also in the filter.
The filter you can use is:
Customer.SETFILTER( "Salesperson Code",'%1|%2','1','2');
Customer.SETFILTER( "Salesperson Code",'%1|%2','1','8');
Operator Description
.. Range
& And
| Or
< Less than
<= Less than or equal to
> Greater than
>= Greater than or equal to
<> Different from
* Forms a part of value
@ Case-insensitive
have tried
Customer.SETFILTER("Salesperson Code",'%1..%8','1','8'); which only gives me the first page!
I am guessing I am missing something really silly, but I have only been working with NAV for a month!
Customer.SETFILTER( "Salesperson Code",'%1..%2','1','8');
Alternatively you could just use..
%2 = second parameter
Now you used %8 and that is the eightst parameter. Only you never used a 8st parameter in your statement.
Customer.SETFILTER( "Salesperson Code",'%1|%2','1','8');
Translation:
Set a filter on the customer-tabel ( Customer.SETFILTER)
on the field "Salesperson Code" ( "Salesperson Code" )
Use as filtervalue parameter 1 OR parameter 2 ( ,'%1|%2' )
use for the first parameter the value '1' ( ,'1' )
use for the second parameter the value '8' ( ,'8')
Smaller or equal to 8 and not 11.
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03