Form Filter Trigger
 
            
                
                    raiees                
                
                    Member Posts: 33                
            
                        
            
                    Hi,
I have a form , it has an option field Status Current and History.
I have put a option control 'Show Options' in the form to filter the status field
If status 'Current Only' is selected, the form displays all current records and if status 'History only' is selected the forms shows all History records.
if user chooses Form filters (Field Filter Table Filter and Show All), the form shows accordingly and overruled the option control filter and option control shows wrong status.
My question is how we can track form filters so I can change option control accordingly.
Thanks in Advance
                I have a form , it has an option field Status Current and History.
I have put a option control 'Show Options' in the form to filter the status field
If status 'Current Only' is selected, the form displays all current records and if status 'History only' is selected the forms shows all History records.
if user chooses Form filters (Field Filter Table Filter and Show All), the form shows accordingly and overruled the option control filter and option control shows wrong status.
My question is how we can track form filters so I can change option control accordingly.
Thanks in Advance
0                
            Comments
- 
            Let me see if I can get you to clarify a bit.
 So (for example) You're looking at a customers ledger entries.
 You want a textbox at the bottom of the page called status.
 The status button has 3 options
 1.View All
 2.View Current
 3.Vew History
 when selecting one of these options you want the form to filter.
 In this case I will use the field "OPEN" to determine what is current and what is history
 am i in the ballpark?0
- 
            If I understand correctly, problem is, that when user use the standard way to set filter, the added fields for filtering are not "in sync" the reality.
 There is no such trigger for setting filters. You need to get the actual filters and set the values to correct one e.g. in OnAfterGetRecord because each time you change filter, lines are re-readed. But you should optimize it to not seth the values when not needed...0
- 
            Hi Savatage,
 Yes you are right.
 I have done up to your point.
 But as Kine said, my problem comes when user uses standard filter.
 When user says View Current so customer ledger entries form shows all open entires but after that user uses standard filter Show All (Shift+Ctrl+F7) so now the form shows all entries but my option button shows Current only. so it is not 'sync'
 Kine,
 As you suggested If I get the filter in OnAfterGetRecord, every time records are updated, will execute my code. I want to execute it when Standard filter is set.
 Any suggestion?0
- 
            Here the source that kine means.if getfilters(YourOptionFieldinTable) <> '' then begin //here u set the values for the YourOptionTextboxVariable end else YourOptionTextboxVariable := ''; 
 But why do you which a TextBoxControl for filter? Only for more "easely filter for the user or why. Why the users not use Ctrl+F7.With Ctrl+F7 they are more flexible.
 Like a filter with F7 on YourOptionFieldinTable:
 <>Open&<>Closed&<>Checked
 Would you add all possible filtercriterias to your YourOptionTextboxVariable? I Think not, so why not using the default Filterfunction (Ctrl+F7 or only F7 if the field is enabled)?
 RegardsDo you make it right, it works too!0
- 
            Hi Garek,
 Thanks for your input.
 They need only one filter 'Status' on the form, users say the filter is visible on the form so easy to know it. and they can use Field or Table filter for other fields
 Its Users wish and we need to fulfill :P0
- 
            Just create a function to update the form based on the filter and call this on after get record.
 MyFunction()
 Case GETFILTER(Status) OF
 'Current':
 IF MyStatus <> MyStatus::Current THEN
 MyStatus := MyStatus::Current;
 'History':
 IF MyStatus <> MyStatus::History THEN
 MyStatus := MyStatus::History;
 Else
 BEGIN
 SETRANGE(Status);
 MyStatus := MyStatus::All;
 END;
 END;
 This will allow for the filter to be set from the fieldfilters, and your existing code from the form, if you want your form variable to set the filter
 MyFunction()
 Case GETFILTER(Status) OF
 'Current':
 IF MyStatus <> MyStatus::Current THEN
 SETRANGE(Status,Status::History);
 'History':
 IF MyStatus <> MyStatus::History THEN
 SETRANGE(Status,Status::Current);
 Else //Set to Default
 SETRANGE(Status,Status::Current);
 END;
 DavidAnalyst Developer with over 17 years Navision, Contract Status - Busy
 Mobile: +44(0)7854 842801
 Email: david.cox@adeptris.com
 Twitter: https://twitter.com/Adeptris
 Website: http://www.adeptris.com0
- 
            Hi
 Another suggestion is to use FILTERGROUP so the the end user cannot remove your filter and then change it by the option selection.0
- 
            Thanks David,
 I had already coded as you suggested here but I liked Dave idea to use FILTERGROUP.
 Now user can only filter from option button only.
 Thanks for all0
- 
            I've added a Global Variable Called: ViewStatus type option
 The Options of this field Are: "View All", "View Current","View History"
 I added a textbox to the bottom of the form: SourceExp=ViewStatus
 Make sure your glues are bottom, left
 Add this code to the Textbox c/al codeOnAfterValidate() CASE ViewStatus OF ViewStatus::"View All": BEGIN RESET; SETCURRENTKEY("Entry No."); SETFILTER("Customer No.","Customer No."); END; ViewStatus::"View Current": BEGIN RESET; SETCURRENTKEY("Entry No."); SETFILTER("Customer No.","Customer No."); SETFILTER(Open,'Yes'); END; ViewStatus::"View History": BEGIN RESET; SETCURRENTKEY("Entry No."); SETFILTER("Customer No.","Customer No."); SETFILTER(Open,'No'); END; END; CurrForm.UPDATE;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
- 322 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




