Default Values
When defining a data service, a user may have an requirement, that even if a user has not entered a specific parameter value in a request, a default value should be automatically added to the query. This can be done using the default values feature that is found when defining a query.
Default values are added when defining queries. Therefore, even if a user has not entered a specific parameter value in a request, a default value gets automatically added to the q uery. For example, shown below is how a default value is set for an Input Mapping in a query:
Referring to Internal Property Values using Default Values
Special system variables are defined which can be used as default values. At the moment, it only provides a variable for retreiving the username of the current user authenticated in a secured data service. This variable can be accessed using the following syntax:
#{USERNAME}: Dynamically replaces the input mapping with the current user's username when a data service request is processed. #{NULL}: Sets the current input mapping value to null. It's the same as providing "xsi:nil" in the incoming message's input parameter element. #{TENANT_ID}: Represents the current tenant ID. This is useful in a Stratos deployment where multiple tenants live in the same server. #{USER_ROLES}: This value contains the list of user roles that the current calling user has. If the parameter mapped is of type ARRAY, it will have the full list of user roles. If it's a SCALAR, it will only contain the first user role of the user.
For a demonstration of the usage of default values, refer to example " Default Values Demo " in the Data Services Server 3.0.0 Documentation.