Report: SETFILTER on a option field
mgerhartz
Member Posts: 50
Hi,
I've got the following problem: I want to enable the user to set a filter in the request form. For example, the field I want to filter is an option field. The user enters a content like blue, green, yellow or what ever, and the SETFILTER function should compare the content of the request form field with the content of the option field. If it match, the filter has to work otherwise it has to show an error, like "unknown content, please retry". I know how the SETFILTER function works. But I have no idea, how it works with an option field. Do I have to write code for every possible option?
Thanks a lot for your help!
Markus
I've got the following problem: I want to enable the user to set a filter in the request form. For example, the field I want to filter is an option field. The user enters a content like blue, green, yellow or what ever, and the SETFILTER function should compare the content of the request form field with the content of the option field. If it match, the filter has to work otherwise it has to show an error, like "unknown content, please retry". I know how the SETFILTER function works. But I have no idea, how it works with an option field. Do I have to write code for every possible option?
Thanks a lot for your help!
Markus
0
Comments
-
Maybee something like this?
IF Vertragsfilter <> '' THEN BEGIN
CASE "Workflow Vorlage".Vertragslage OF
"Workflow Vorlage".Vertragslage::Buchungsvertrag:BEGIN
"Workflow Vorlage".SETFILTER("Workflow
Vorlage".Vertragslage,Vertragsfilter);
END;
IF "Workflow Vorlage".FIND('-') THEN BEGIN
ELSE
ERROR('Ungültige Option');
END;
and so on....
Do I have to write code for every possible option? And there is still an syntax error. Please help :-k0 -
Dear mgerhartz,
you will first have to define the possible options, which the user can select from.
Within the report create a global variable, data type Option. Then select the properties of it. In the OptionString you can enter the possible options seperated by a , (komma). After this you can program what the report should do with the selected option.
If you define the options in the table, you can filter the option, without additional programming.
kind regards.0 -
If you want that the user only selects 1 option it is easy.
Create a global (e.g. optMyOptionField) that is an option and has the same options as your field.
To test it:recMyRecord.RESET; recMyRecord.SETCURRENTKEY("My Option Field"); recMyRecord.SETRANGE("My Option Field",optMyOptionField); IF NOT recMyRecord.FINDFIRST THEN ERROR('Not valid');
Some remarks:
1) SETRANGE can be faster then SETFILTER
2) SETCURRENTKEY if you have a key on that field and will be a lot faster then a key on another field
3) FINDFIRST for 4.0SP1 and FIND('-') for older versionsRegards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Hey Guys,
thank you so much for your help. I will try it and let you know if it works.
Byby
Markus0 -
Hey Guys,
I solved my problem in a total differend way. I've created a varible with the type of option. Then I wrote in the section:
IF Vertragsart = WF.Vertragslage THEN BEGIN
CurrReport.SHOWOUTPUT((Structure."Organization Type"=Structure."Organization Type"::State) AND (firstsection = FALSE));
END ELSE BEGIN
CurrReport.SHOWOUTPUT(FALSE);
END;
It works fine. Thanks again to the Guys who gave me reply to my question.
Have a nice day
0 -
You can use an option field/variable in SETRANGE like this:
MyRec.SETFILTER(MyOptionField,'=%1',MyOptionField::Value);
For some reason SETFILTER doesn't know how to interpret optionstrings directly, but by using the % notation it should work.0 -
Or better:DenSter wrote:You can use an option field/variable in SETRANGE like this:MyRec.SETFILTER(MyOptionField,'=%1',MyOptionField::Value);
For some reason SETFILTER doesn't know how to interpret optionstrings directly, but by using the % notation it should work.MyRec.SETRANGE(MyOptionField,MyOptionField::Value);
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
You said that before, but I am still not convinced that it is any faster.0
-
Not always, but it is NEVER slower, and it has the potential to be faster.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
I've also heard that setrange is faster in certain times and my rule is that to use setrange always, unless it's a complicated filter, and then use setfilter in those circumstances0
-
Exactly what I do!ara3n wrote:I've also heard that setrange is faster in certain times and my rule is that to use setrange always, unless it's a complicated filter, and then use setfilter in those circumstancesRegards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
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
- 610 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

