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:
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
Comments
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"); ?
So I have taken a different approach:
The form will sort by order no. on opening.
So I made the following function:
I call this from my Timer function and a dedicated button.
I hope this helps people out!
Interesting discovering this!