Sample - SQL Report - How To Keep Last Parameter Value in Query
Sample - SQL Report - How To Keep Last Parameter Value in Query
Date: 19/02/2017
Summary
Module Universal functions
Level Advanced
Requirements B1UP 2015.08 or higher
Description
This sample will show you how to keep the last parameter values entered so that there is no need to
enter the value every time. You will only need to update the fields required if you need changes.
Pre-Requisite
In this example we have a query on Sales Orders information with 4 parameters, ‘From Date’, ‘To
Date’, ‘From BP’ & ‘To BP’ please see query below.
This Query when run will pop up the following screen prompting user to fill in the values every time. If
user wants to run it with a different set of BPs then they have to enter the Dates again.
So in order to help user to save this hassle, we will first create a User-Defined Table with 4 fields. Each
field will correspond with each of the parameters and put in some values to start.
.
Copyright 2011 – Boyum IT A/S Page 1/3
B1 Usability Package Sample
We will now create a Menu Item for the SQL Report. (Note: you can assign this function to a button or
any other Validation event, it is optional to create a menu item)
Under the Function Column, we will create our new Universal Functions.
Universal Functions
We will create a Universal Function of the type SQL Report. We will create 4 variables making them
equal to the fields from the User-Defined Table that we just created. The Query is as below:
We also need to make sure select the Refresh Data Button option.
Next we will run this SQL report. When the Report is displayed, we will right click and select ‘B1
Usability Pack’ > Add or Edit Function Button.
Then in the Button Configuration, we give the button a name and assign a new Universal Button which
Open the User-Defined Table. This will allow user to Update the values of the parameter.
Then we go to Tools > User-Defined Windows, locate our User Defined Table and hover our arrow on top
of the table. We can then look at the lower left hand corner to find out about the Menu UID of this table.
In my example, the Menu UID is 51285
We will now create our second Universal Function and Assign it to the Set Parameter button that we just
created. The Syntax is just Activate(51285); using the Menu UID that we just found out. Then we Add this
function and another Add when back in the Button Configuration window.
Result
When menu item of the Sales Order SQL Report is click, the SQL report will be displayed using the initial
values we put in the User-Defined Table. If customer wants to change the parameter, say now they want
to see Sales Order for the year 2006 as well, then all they have to do is to click the ‘Set Parmeter’ to open
the User Defined Table to update the parameter value
In our example we are changing the FromDate to 01/01/2006 and click Update.
Back in the SQL Report, user will need only to click the ‘Refresh’ button to see fresh data. This will save
them the need to re-type the other parameters.