Options

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

David_SingletonDavid_Singleton Member Posts: 5,479
edited 2010-07-03 in NAV Tips & Tricks
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.
David Singleton

Comments

  • Options
    David_SingletonDavid_Singleton Member Posts: 5,479
    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 Singleton
Sign In or Register to comment.