Pass paramater to a form (or SubForm) using RUNMODAL or RUN

David_Singleton
Member Posts: 5,479
There are a few ways to pass a parameter to a form. The most common is to define a variable of type FORM create a function in that form and call the function to set parameters.
There are a few cases where it is not possible or not ideal to do this. For example calling a form from a button on another form, or a SubForm. Lets say you need to pass a value from the sales header to the sales line. Or you want to open the customer card from a sales header but pass a parameter across. You can do this using a single instance code unit, but a simpler way is just to add the parameter to the filters that are set on the form.
So lets say the Sales Header has FieldX and you want the value in this transferred to the Sales Line SubForm. Create the same field in the Sales Line table. Set the propertied identical, EXCEPT, set the Class to FlowFilter.
Now in your SubForm link properties set the two fields to link to one another. Now in the sales line sub form you can get the parameter by using MyValue := Getfilter(FieldX);
You could also do this if you want the value on the customer card when you press Shift+F5 form the sales header.
The solution is a bit of a hack, but simple, and also if you just need to view the value, then you don't even need access to code, so handy for end users with just the Table and Form designers.
There are a few cases where it is not possible or not ideal to do this. For example calling a form from a button on another form, or a SubForm. Lets say you need to pass a value from the sales header to the sales line. Or you want to open the customer card from a sales header but pass a parameter across. You can do this using a single instance code unit, but a simpler way is just to add the parameter to the filters that are set on the form.
So lets say the Sales Header has FieldX and you want the value in this transferred to the Sales Line SubForm. Create the same field in the Sales Line table. Set the propertied identical, EXCEPT, set the Class to FlowFilter.
Now in your SubForm link properties set the two fields to link to one another. Now in the sales line sub form you can get the parameter by using MyValue := Getfilter(FieldX);
You could also do this if you want the value on the customer card when you press Shift+F5 form the sales header.
The solution is a bit of a hack, but simple, and also if you just need to view the value, then you don't even need access to code, so handy for end users with just the Table and Form designers.
David Singleton
0
Comments
-
Oh and this can also be used to pass "Hard Codded" parameters to a form.
Lets say you have one form that is used for three different purposes, you can create a field in the Table e.g. FormUsage::" ,Sales,Purchase,Secure" then just set that as a constant in the button properties and then you can show or hide fields depending on which parameter was used in the button.
This is less effective now than it was when we had the Form330 menu.David Singleton0
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