Heyho,
I´m absolutely new in Navision and run through basic training at the moment. While getting started with Form Design, I shall use the "Form\SourveTableView"-Property to filter all records with a certain value in a certain field.
The Property value looks like "WHERE(Emplymt. Contract Code=CONST(ADM))" from the Cronus Trial Company. It shows only the records from table "Employee" with value "ADM" in field "employment contract code".
My Question:
To set the Table Filter, the guide manual told me to use "CONST" as filtertype. Why is it "CONST" and not "FILTER"? is there any difference at all? If I replace "CONST" with "FILTER" the result seems to be the same.
0
Comments
CONST is short for Constant (never changing)
The FILTER is used where you need to have a condition such as >0 or a range of values.
Well, the example from guide manual is probably not very suitable to show that difference. in that concrete example, it makes no difference if i use "FILTER" or "CONST". I think as long as the value of the referred field has a fix value (code "ADM" in field "eplymt. contract" in the example is deposited once and normally doesn´t change) it doesn´t really care.
You mean, if the value in the source-field can present a range of different values, "FILTER" is more suitable?
Dmitry
Hello Guybrush (I like these games :-)
not exaclty, you will use CONST if you have just ONE value you want to filter. You will use FILTER if you have MORE values or indefinite value... And another point of view: value in CONST is taken as VALUE, if you enter '' it does not mean empty string but value with two apostrophe. If you enter '' into FILTER, it will mean empty string. If you enter A|B into CONST, it will be filter for one value 'A|B'. If you enter A|B into filter, it will be filter to two walues - A or B. :-)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
If you take notice of the code in the standard Navision you will notice that CONST is always used where possible so as a good developer, it is always best to go with the standard.
This is rule no #1 for all developer issues =D>
Kline answered the Question with 1 Value Const, more than one Filter.
I would say one thing though, in the examples, they tend to Hard Code these CONST values, but as a good practice "Never Hard Code", but use a setup table, then the values can change with the business, without to much trouble.
MySetup.GET;
MySetup.TESTFIELD("My Default");
MyRecord.RESET;
MYRecord.SETCURENTKEY(Code);
MYRecord.SETRANGE(Code,MySetup."My Default");
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
FILTER is for dynamic filters, where the value of a certain field depends on the value of a related field in another table.
Take a look at the form link between the sales header and the sales line in the order forms. The document type has a static filter (CONST) on the required document type, and the document number has a dynamic filter (FILTER), where the Document number of the header record equals the document number of the line records.
RIS Plus, LLC
The link for the document no. is set in the SubFormLink; the Document type is set in the subform with the SourceTableView
Navision uses FILTER for this, not CONST
I don;t know why actualy, I remember experimenting with it a long time ago but I don;t remember the outcome.
I agree but he is following an example that says use the CONST, a bad practice for 'ADM', but ok for "Document Type"=CONST("Document Type"::Order), or MyFlag=CONST(TRUE).
Not a good training example to follow, maybe someone can point him in the direction of better training material.
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com
I use the Navision Programming I and II training guide from "Navision – PC&C Personal Computing and Communications Vertriebs GmbH, Hamburg". It is an official training guide for 5 day Navision Programming Seminar. *g*
Although, that´s no indicator about the quality. My main problem with this guide are the solution-examples. Each lesson had a example how to solve. but they only write "do this and then do that". no word, WHY I should use that certain value or code-snippet. so I can only learn how things happen but not why they happen. for the example on top of this thread it seems to make no difference if i use "CONST" or "FILTER", and there´s no explaination why there´s "CONST" and not "FILTER". Perhaps it´s my problem, that at the seminar, the whole guide is moderated by a trainer and actually I read it for myself and try to understand ...
If anyone know training guides better suitable, please fell free to post a link or send me an pn.
You're right I was wrong..... obviously you don't use FILTER for dynamic linking. I was going off the top of my head, when I am programming this type of stuff I don't even read the property values anymore, I just click them. In my head I call it a FILTER, but it's a FIELD link, and it's not in the SourceTable property. I just wanted to illustrate the difference, and I may have confused Guybrush even more...
I guess the difference between CONST and FILTER is that with CONST you can enter one value, and with FILTER you can enter a filter string. If you want to know more about this, read what F1 help says about it, or go into the C/SIDE Reference guide and search for the property.
Sorry about the confusion, I was rushing, I should take more time for posts like this.
RIS Plus, LLC