Scroll

Custom Filter Functions

Custom Filter Functions provide the ability to make functions that will dynamically calculate a value for a filter using high level code.

Filter Functions can be written in C#, JavaScript, or VB. Net.

Filter Functions written in C# and VB.Net can get and set elements from the current session of Exago, such as Parameter values. See Exago Session Info for more information.

 

Creating Filter Functions

To create a custom function, highlight the Filter Functions tab within the Extensions menu of the Admin Console and click icons.add.png Add.

Each Custom Filter Function has the following properties:

Name

A name for the filter function that will be displayed to the end users.

Description

A description of the filter. 

Note: To support multi-language functionality, if the filter function’s name or description can be prepended with ‘_wrFunctionId’. If this ID matches the ID of any element in the language files, then the string of that language element will be displayed to the user instead of the function name/description. For more information see Multi-Language Support.

Filter Type

Determines the data type that the filter function should be available for. This includes date values, strings, integers, and decimals. 

List Order

The order the filter function will appear among other filter functions of the same type. Functions with a lower number will appear higher on the list. If two functions have the same list value they will display in alphabetic order.

Note: All of the built in filter functions start with list value 100 or greater.

screen.CFF_info.png

Language

The high-level language of the code for the date function. May be C#, JavaScript, or VB.Net.

Reference

A semicolon-separated list of any .dlls that need to be referenced by the Custom Filter Function. If the .dlls are not accessible in the GAC then the .dlls must be copied to the 'Bin' folder of Exago or the reference should point to their physical path.

Note: System.dll does not need to be listed as a reference as it is already available.

Program Code

The program code for your Custom Filter Function. The code must return the data type that was set in the Filter Type setting. 

Note: Parameters may be referenced within custom functions by placing their name between @’s.

screen.CFF_code.png

A Custom Filter Function that returns the date value of the last day of the current quarter

Press the Test custom code execution greencheck.png icon to verify that the code properly executes. 

 

Advanced Example

The following is an example of a Custom Filter Function that calls the database to generate the average value of a field so it can be used as a benchmark for a filter. This Custom Filter Function will be used to simulate a threshold for the average discounted price off all Orders.

Name: AvgFilterBenchmark

Description: Average Filter Benchmark: Calls the database to generate the average value of a field so it can be used as a benchmark for a filter.

Filter Type: Decimal

List Order: 100

 

Language: C#

References: SQLUtils.dll;System.Data.dll;System.Xml.dll

Namespaces: System.Data;SqlUtils

Program Code:

//Establish connection with the Data Source
DbSqlHandler sql = new DbSqlHandler(
DbObjectFactory.DataSourceType.SqlServer,
"Server=<server>;Database=<db>;uid=<username>;pwd=<password>;"
);

//Set SQL statement
//Take an average of the discount of all order detail records
sql.Stmt = String.Format("SELECT AVG(Discount) FROM OrderDetails");

//Send the SQL off to the Data Source
DataSet ds = sql.ExecuteReadCmd();

//Return the average value
return Convert.ToDecimal(ds.Tables[0].Rows[0].ItemArray[0]);

Hidden Article Information

Article Author
Alexander Agoado
created 2015-12-30 17:40:41 UTC
updated 2018-12-19 15:00:49 UTC

Labels
Date Functions, session info, sessionInfo, filter functions,
Have more questions? Submit a request