In Sage X3, we may come across a situation where we need to create SQL query tool by adding fields from the table.
There was one requirement from one of our clients to add parameters (filters) for the SQL query tool in the criteria tab.
In this blog, we will explore the process of assigning parameters to the SQL query tool based on client-specific requirements. So, we have added two parameters, ‘From Date’ and ‘To Date’.
We will see this functionality in detail in this blog:
Path>>setup>>Usage>>Reports>>SQL query tool
Initially, formulate a SQL query in accordance with the client’s requirements. When incorporating parameters into the SQL query, ensure to enclose the parameter number within %% symbols as shown in the above screen shot.
For Example:
select * from SINVOICE where SINVOICE.INVDAT_0 between %1% and %2%
Path >> setup >> Usage >> Reports >> SQL query tool >> Parameter
Navigate to the Parameters tab and add the necessary parameters, specifying the desired data type. If a default value is needed for a parameter, enter the default value in the ‘Default’ column.
We have added ‘Date From’ and ‘Date To’ to the Parameter column, assigning a default value using the current date$ function.
After adding the parameter, click on the ‘validate’ button to validate the query, and then click on the ‘Run‘ button to execute it.
Path : Path >> setup >> Usage >> Reports >> SQL query tool >> Run button
Click on the ‘Criteria‘ button.
So, in conclusion, we have successfully added parameters to this query tool. Now, users can manually enter the required parameters, click on ‘Ok,’ and filter the query according to their specific needs, thereby enhancing the flexibility and usability of the report.