Sorting by Flowfield - on demand/timer, frm already filtered

shogan@mila.ie
Member Posts: 113
Hi all,
I have a form based on the Sales Order List, that has a filter applied to the Credit Status field. It refreshed using OnTimer every 10 seconds.
What I would like to do is sort it by Credit Status, however it is a flowfield.
I am wondering if anyone would object to the following way I am doing things:
On the Sales Header table, I have a new Credit Status - Sort field created.
On the form itself:
As the form can be sorted with custom buttons, I have applied a new "Sort by Credit Status" button, with the following code:
Credit Status is an option field, however Credit Status - Sort is a text field.
I only need to apply the sort on the records currently filtered when opening/refreshing the form, and not the entire Sales Header table.
I have been looking at code where people wanted to sort by Customer Balance or Sales (LCY) and there was mention of outputting to a different table, or updating a field on the current table, with REPEAT, RESET, FIND('-'), and letting a new field equal the old one. Also, there was talk of looking at the Top 10 reports.
I think I have it simplified somewhat in my approach above; just wondering if I should/need to lock the Sales Header table, despite the fact that it is an inexpensive task.
Thoughts welcome.
Regards,
Stephen
I have a form based on the Sales Order List, that has a filter applied to the Credit Status field. It refreshed using OnTimer every 10 seconds.
What I would like to do is sort it by Credit Status, however it is a flowfield.
I am wondering if anyone would object to the following way I am doing things:
On the Sales Header table, I have a new Credit Status - Sort field created.
On the form itself:
Form - OnAfterGetRecord() CALCFIELDS("Credit Status"); "Credit Status - Sort":= FORMAT("Credit Status");
As the form can be sorted with custom buttons, I have applied a new "Sort by Credit Status" button, with the following code:
btnSortCrStatus - OnPush() SETCURRENTKEY("Document Type","Credit Status - Sort","No.");
Credit Status is an option field, however Credit Status - Sort is a text field.
I only need to apply the sort on the records currently filtered when opening/refreshing the form, and not the entire Sales Header table.
I have been looking at code where people wanted to sort by Customer Balance or Sales (LCY) and there was mention of outputting to a different table, or updating a field on the current table, with REPEAT, RESET, FIND('-'), and letting a new field equal the old one. Also, there was talk of looking at the Top 10 reports.
I think I have it simplified somewhat in my approach above; just wondering if I should/need to lock the Sales Header table, despite the fact that it is an inexpensive task.
Thoughts welcome.
Regards,
Stephen
0
Comments
-
hi,
it should work, because is u use a filter after that u change the sorting, than sorting applying for filtered records.
Did you called MODIFY after this: "Credit Status - Sort":= FORMAT("Credit Status"); ?0 -
Actually no, I didn't - let me test that (and thanks for the reply!)0
-
So I cannot use MODIFY; within the OnAfterGetRecord() trigger:"You cannot make any changes in the database until a transaction has been started"
So I have taken a different approach:
The form will sort by order no. on opening.
So I made the following function:fCreditStatusSort() // 2014-07-18 shogan@mila.ie ----- START // Function to assist sorting the form by 'Credit Status'. // Writes value from 'Credit Status' flowfield to 'Credit Status - Sort' text field. IF FIND('-') THEN REPEAT CALCFIELDS("Credit Status"); "Credit Status - Sort":= FORMAT("Credit Status"); MODIFY; UNTIL NEXT = 0; // 2014-07-18 shogan@mila.ie ----- END
I call this from my Timer function and a dedicated button.
I hope this helps people out!
Interesting discovering this!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
- 320 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