View source | View content page | Page history | Printable version   

Projects:Selector/Default Filter Expressions

Warning.png   This document is still a work in progress. It may contain inaccuracies or errors.



The New Selectors provide an easy way to define selectors using the Application Dictionary (AD) without coding. The Default Filter Expression is the way to define expression that will be used by the selector data-source for filtering information.

Note: The changes will be associated with the Issue 13458

Technical Details


Preliminary API

// Document related functions
OB.isPosted(); // returns true/false if the document is posted
OB.isProcessed(); // returns true/false if the document is processed
OB.isSalesTransaction(); // returns true/false based on the type of window
// Data from Window/Tab
OB.getWindowId(); // returns a string with the record ID of the window
OB.getTabId(); // returns a string with the record ID of the tab
OB.getCommandType(); // returns the type of command
// Accessing the context
OB.getContext().getUser().id; // gets the current user record ID based on the context
OB.getContext().getCurrentClient().name; // gets the current client name
// Accessing the HTTP session
OB.getSession().getAttribute('#AUTOSAVE'); // access the HTTP session and get an attribute
// Accessing the HTTP request
OB.getParameters().get('inpParamName'); // Returns the String value of the inpParamName request parameter

Check all public getters of this class OBBindings

Filter Expression at Selector level

The HQL where clauses defines a fixed where that is applied always when fetching data from the database. With the new 'Filter Expression' we can add dynamic HQL where clause that can be applied only in some cases, e.g. Always filter Business Partner for type 'customer' when is a Sales Transaction.


if(OB.isSalesTransaction() === null) {
} else if (OB.isSalesTransaction() == true) {
  "e.customer = true";
} else {
  "e.vendor = true";
Bulbgraph.png   Note: The entity in the HQL has an alias e that needs to be used

Default Expression at Selector Field level

The default expression is also a JavaScript expression that can use the same OB object API, that defines a default value for field in the selector. Depending on the definition of the field, the user can remove the that default value in the selector grid popup.


Suppose that you are defining that you want to always filter by Business Partner type 'customer'.


Example 2a

Suppose that you want to filter the description field of the product selector in Sales Order Lines with the value from the Sales Order (header) description.

Bulbgraph.png   Note: The db-columnname needs to be specified in uppercase

Example 2b

The use case of this is very similar to Example 2a. But instead of a default Filter we'll use the 'Dynamic Filter Expression' to apply the filter directly so the user cannot remove it in this case. Also we enhance the example by not embedding the needed windowID as a constant but retrieve the current window id in the expression to make the selector transparently work with more than one window.

Bulbgraph.png   Note: The example still needs the description field to be marked as 'Store in Session' for each window the selector should be used in.
"e.description = '" + OB.getSession().getAttribute(OB.getWindowId() + '|DESCRIPTION') + "'"

Retrieved from ""

This page has been accessed 12,464 times. This page was last modified on 8 June 2012, at 05:30. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.