I have a custom form with a button on it. When I click a button, I want to open Item List form, where data is sorted according to Seach Code.
I would imagine this code should solve my question:
Item.RESET;
Item.SETCURRENTKEY("Search Code");
ItemListForm.SETTABLEVIEW(Item);
ItemListForm.RUN;
However, this only works if SourceTableView is not defined. If there is a key defined in SourceTableView property, then this code is useless. Is there any other way of defining a sorting key and forcing it over a predefined key on SourceTableView property?
Thanks for ideas!
Answers
Hope its clear
I quickly did the following;
1. Added a new button to a form and added the following to the OnPush trigger:
OnPush
Local Var: Item Record: Table 27 Item
Local Var: ItemList Form: Form 31 Item List
//Code...
Item.SETCURRENTKEY("Search Description");
CLEAR(ItemList);
ItemList.SetKey(Item);
ItemList.RUNMODAL;
2. On the Item List form I added the following function: SetKey and a Global Variable GlobItem
3. The SetKey function looks like this...
Setkey(VAR pItem : Record Item)
//Code...
GlobItem.SetView(pItem.GetView);
4. On the OnOpen trigger add the following code
OnOpen
IF GlobItem.CURRENTKEY <> CURRENTKEY THEN
SETVIEW(GlobItem.GETVIEW);
I hope this helps ;-)
Cheers,
R
Ritesh K Singh
This works ONLY when we do not have SourceTableView property defined to something like SORTING(No.).
Dynamics NAV Enthusiast
Thanks (ačiū), that is the way I went forward.
Dynamics NAV Enthusiast
<edit>corrected spelling, with my apologies to all the German speaking peoples of the world </edit>
RIS Plus, LLC
MVP - Business Apps
Daniel, Gesundheit you must write with an "d" not with an "t"
@Thomas: Gesundheit (Bless you)