Run a form with predefined key
Tomas
Member Posts: 420
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:
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!
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!
Tomas,
Dynamics NAV Enthusiast
Dynamics NAV Enthusiast
0
Answers
-
Create procedure within this form and by using it store global variable value. Then in triger OnOpenForm change the key
Hope its clear0 -
Hi Tomas,
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,
R0 -
I tried this and it works...Item.RESET;
Item.SETCURRENTKEY("Search Description");
IF Item.FINDFIRST THEN
ItemList.SETTABLEVIEW(Item);
ItemList.RUN;Thanks,
Ritesh K Singh0 -
ritesh.singh wrote:I tried this and it works...Item.RESET;
Item.SETCURRENTKEY("Search Description");
IF Item.FINDFIRST THEN
ItemList.SETTABLEVIEW(Item);
ItemList.RUN;
This works ONLY when we do not have SourceTableView property defined to something like SORTING(No.).Tomas,
Dynamics NAV Enthusiast0 -
i4tost wrote:Create procedure within this form and by using it store global variable value. Then in triger OnOpenForm change the key
Hope its clear
Thanks (ačiū), that is the way I went forward.Tomas,
Dynamics NAV Enthusiast0 -
GesundheitTomas wrote:ačiū
<edit>corrected spelling, with my apologies to all the German speaking peoples of the world
</edit> 0 -
This may be a dumb question, but this is your custom form, you want it to sort this special way, then why are you setting the SoruceTableView in the first place, why not just use the code suggested, and not define the SoruceTableView on the form ?Tomas wrote: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!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
