Queries and tokens

Queries are used to customize views, retrieve search results, and configure lookups.

You can use tokens to construct your queries in the Query form. Tokens are placeholders. Optiva evaluates the actual value of a placeholder according to the context of a query; then Optiva creates and submits the evaluated SQL query to the relational database.

There are four categories of tokens:

  • Simple value tokens, such as [%1], [%2].
  • Tokens for Lookups, such as [%OBJECTSYMBOL}.
  • Action queries that are used by the TableLookup and TableLookupEx functions.
  • Tokens for Pending Task queries

Tokens for Lookup queries

This table shows the tokens that are used for Lookup queries:

Lookup Token Description
[%LAB] This token is replaced with the lab that is currently active for this user for the Optiva session.
[%USER] This token is replaced with the user code for the current user.
[%GROUP] This token is replaced with the group that is currently active for this user for the Optiva session.
[%%GROUPS] This token is replaced with all of the groups for the current user.
[%%OBJECTSYMBOL] This token is replaced with an Optiva symbol.
[%%REFOBJECTSYMBOL] This token is replaced with a reference symbol.
[%%REFOBJECTKEY] This token is replaced with a reference symbol and a reference key.
[%OBJECTKEY] This token is replaced with an object key.
[%%ROLES] This token is replaced with all of the roles for the current user.
[%LANGUAGE] This token is replaced with the language code for the current user.
[%%LIKECLAUSE] This token is replaced with a starting value.

Tokens for Action queries

This table shows the tokens that are used for Action queries:

Action token Description
[%USER] This token is replaced with the user code for the current user.
[%LAB] This token is replaced with the lab that is currently active for this user for the Optiva session.
[%GROUP] This token is replaced with the group code that is currently active for this user for the Optiva session.

Tokens for Custom Pending Task filters

Using the SQL token [%LAB], you can create a custom Pending Task filter. This filter can limit the display of objects based on the user’s current lab code. These tokens are also supported.

  • [%%USERROLES]
  • [%%GROUPS]
  • [%LAB]
  • [%USER]
  • [%USERGROUP]
Token Description
%USER This token is replaced with the user code for the current user.
%USERGROUP This token is replaced with the group that is currently active for this user for the Optiva session.
%LAB This token is replaced with the lab that is currently active for this user for the Optiva session.
%%USERROLES This token is replaced with all of the roles for the current user. Use this token with an IN clause of a SQL statement.
%%GROUPS This token is replaced with all of the groups for the current user.