Redirecting a formulary to a grid.
In this tutorial, we will demonstrate the use of macro sc_redir and we will also use the macro sc_apl_conf. As an example, we use the table order (for the form) and order_detail (for the grid), making a sc_redir on the form, passing the primary key as a parameter and sending for the detail, that it's configured with sc_apl_conf macro that will display only 1 record per page.
Initially we will have a button to redirect the form to the grid, with the parameter passing the orderid field.
Now the redirection button is done, we have to configure the receipt of the redirect parameter on the grid, on the “SQL” option on Scriptcase, and we will do a where and declare the variable with the redir made on the form, which was transformed into a global variable.
Now we will use the macro sc_apl_conf to provide only 1 record per page on the grid, if it have 2 or more records.
On the form, we will select a record, verify the primary key, and hit the button to redirect the detail that we did.
And on the detail, we have only the records that have the same key, and we used the macro sc_apl_conf to configure the application to show only one record, will be this:
Another example of using the macros sc_redir and sc_apl_conf
Both macro sc_redir and sc_apl_conf, have other features besides those that we've mentioned before. We can use the macro sc_redir redirect from an application to a website too. For example:
And we can use the macro sc_apl_conf to start a application form already in insert mode (new), using it on the OnApplicationInit event.