ERP/2.50/Developers Guide/Concepts/AD/Dynamic Expressions
| Developers Guide |
Contents |
Introduction
Dynamic Expressions are used to obtain values that can depend on session values. For example they can be used to to filter the records that appear in a tab by the ones that were created by the user that has logged into the application.
Session values
Depending on how they are defined, there are different kinds of session values.
It is possible to check (as System Administrator) all current values loaded in session in General Setup || Application || Session Variables window.
Types
Session global variables
These values are generated by Java classes and are accessible from anywhere in the application.
Columns
Values for all columns used in a tab are accessible as session variables within that tab.
Additionally it is also possible to set explicitly a column a session value by setting its Stored in Session attribute. This will make this value accessible not only for its tab but also for all the tabs in that window.
Preferences
Preferences allow to define session values. It is possible to define preferences for a single window or for all of them (leaving blank the window field) and for one user or for all of them. Preferences are defined in General Setup || Application || Preference window.
When the attribute value matches with a column name. it will be used as default value for that column overwriting the standard default value for that column.
Auxiliary inputs
Auxiliary Inputs are used to create a session value for a concrete tab. This value can be calculated using a Dynamic Expression and it purpose is to use it in other Dynamic expressions within the tab it is defined for.
Auxiliary Inputs are defined in Application Dictionary || Setup || Auxiliary Input tab.
Accessibility
It is possible that there are different session values types with the same name that are accessible at the same point, in this case (unless it is explicitly specified to take the value in a global session value) the value will be taken following the next approach:
- Try to get a preference with the specified name for the current window.
- If no value has been obtained, try to get a value associated to the current window
- If no value has been obtained, look for a global session value.
Syntax and types in Dynamic Expressions
Using session values
In Dynamic expressions session values are obtained by their name surrounded by at symbols (@). Thus to get the content of a session value called myValue, it would be done typing @myValue@. Doing it in this manner it would follow the accessibility described above, but it is possible to explicitly obtain the global value (if exists) not taken into account the other ones, to do so the value would have a sharp symbol (#) as prefix. In the previous example it would be @#myValue@.
Dynamic expressions types
There are different types for Dynamic Expression, each type kind be used depending on the Application Dictionary object it is defined in. A complete list of all the objects and which kind of expression can use is defined in the next section.
The types are:
Constant
It can a constant value or a value in stored in session, this type can be used by all the objects. To set this type no prefix is needed.
Examples:
1
@#AD_User_ID@
SQL
Some objects accept SQL expressions. This type must have a @SQL= prefix followed by the SQL clause. It also accepts session values.
Example:
@SQL=SELECT DOCSUBTYPESO
FROM C_DOCTYPE
WHERE C_DOCTYPE_ID = @C_DOCTYPETARGET_ID@
WhereClause
It is a SQL where clause, in this case it is not necessary to add the @SQL= prefix.
Checks
It is used to obtain a boolean value. It does not have any prefix.
Its syntax is Javascript but the comparators are:
- = instead of ==
- ! instead of !=
- & instead of &&
- | instead of ||
Dynamic Expressions used in Application Dictionary objects
| AD Column | Type |
| AD_AlertRule.FilterClause | WhereClause |
| AD_AuxiliarInput.Code | SQL |
| AD_Column.ReadOnlyLogic | Check |
| AD_Dataset_Table.WhereClause | WhereClause |
| AD_Field.DisplayLogic | Check |
| AD_Ref_Table.OrderByClause | WhereClause (order by clause) |
| AD_Ref_Table.WhereClause | WhereClause |
| AD_Tab.FilterClause | WhereClause |
| AD_Tab.OrderByClause | WhereClause (order by clause) |
| AD_Tab.WhereClause | WhereClause |
| AD_Val_Rule.Code | SQL |
Commons | Element and Synchronize Terminology

