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
0
Comments
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?
http://www.BiloBeauty.com
http://www.autismspeaks.org
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...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
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?
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)?
Regards
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 :P
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;
David
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com
Another suggestion is to use FILTERGROUP so the the end user cannot remove your filter and then change it by the option selection.
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
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 all
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 code
http://www.BiloBeauty.com
http://www.autismspeaks.org