--- title: "Literal projection" slug: "core-literal-projection" updated: 2026-05-18T13:59:32Z published: 2026-05-18T13:59:32Z canonical: "docs.lobstersoftware.com/core-literal-projection" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.lobstersoftware.com/llms.txt > Use this file to discover all available pages before exploring further. # Literal projection > [!NOTE] > Projection – Abstract > > **Purpose:** Returns a simple fixed value in the context of a search. > > > [!TIP] > > Tooltip > > > > - **Usage**: The [Literal projection](/v1/docs/en/core-literal-projection) returns a simple fixed value, which is determined via a *value configuration* for the **Literal** parameter. > > - **Parameter**: > > - The **Name** field optionally defines the title of an output column (if relevant). The default *name* ist the string image of the value resolver for the **Literal**. > > - The *value configration* for the **Literal** is optional. > > - By default, a value resolver is preset that returns a static empty string (""). > > - Without a *value configuration*, "no value" (`$null`) is considered a **Literal**. > > - **WARNING:** With few exceptions, complex data objects (e.g. dynamic enumeration values) cause error messages as return value for the **Literal**. ![images/download/attachments/78251658/image-2023-10-24_11-29-30-version-1-modificationdate-1698139782480-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image-2023-10-24_11-29-30-version-1-modificationdate-1698139782480-api-v2.png) A [Literal projection](/v1/docs/en/core-literal-projection) returns a fixed value in the context of a search, determined solely by the value configuration for the **Literal** parameter. The [Literal projection](/v1/docs/en/core-literal-projection) is frequently (and often repeatedly) used in the context of a [Concatenated projection](/v1/docs/en/core-concat-projection) to contribute static components to a concatenated text. ## Configuration | Parameter | Type | Description | | --- | --- | --- | | **Name** | String | The optional **Name** parameter can be used to assign an (alias) name to the projection. - If no **Name** is specified, the string image of the value resolver from the *value configuration* for the **Literal** that generates the return value is used as the column name (if relevant). "Static resolvers" usually return their value or a string image of it (e.g. "true"). **NOTE:** The automatically generated column name is only suitable in exceptional cases. If the [Literal projection](/v1/docs/en/core-literal-projection) is at all relevant for the name of an output column, it is therefore recommended to explicitly specify an (alias) name for the column. | | **Literal** | *Undefined* | The *value configuration* determines a return value, which is determined once and enters as a constant in the execution of the query on the database. - A [Literal projection](/v1/docs/en/core-literal-projection) is therefore not "resolved" individually for each row returned from the database. By *default*, a text value resolver (see [Static values](/v1/docs/en/core-literal-value-resolver)) is suggested, since returning a string is the most common use for a static value. Technically, any value resolvers (individually or in combination, see [Chained resolver](/v1/docs/en/core-chained-resolver)) can be used to define a **Literal**. However, not all data types are suitable as *return values* for a **Literal**. - In general, complex values (data objects with multiple fields, e.g. a "Date with time", a "Number with unit" or a dynamic enumeration value) cannot be processed. - Only in special cases certain data types are automatically translated into a data type suitable for the [Literal projection](/v1/docs/en/core-literal-projection) (e.g. "Static enumeration value" → `Long` for the "Ordinal"). | ## Examples ### Typical example: Text concatenation with static components The [Literal projection](/v1/docs/en/core-literal-projection) is used particularly often to combine field contents with static text characters in a [Concatenated projection](/v1/docs/en/core-concat-projection) of a CSV or tuple search. In the following example, in a search on the [Cities](/v1/docs/en/base-city) entity, a reference to the "State" (`state`) is enclosed in brackets and then attached to the place name (`placeName`). | The screenshot shows a [Concatenated projection](/v1/docs/en/core-concat-projection) with four text components: - At positions 1 and 3, one [Property projection](/v1/docs/en/core-property-projection) each accesses a field of the entity. - At positions 2 and 4, a [Literal projection](/v1/docs/en/core-literal-projection) adds a static string to structure the concatenated string: - The first **Literal "** (" contains a space and the opening brackets. - The second **Literal** ")" contains only one closing bracket. **NOTE:** All projections used here do without a specification for the **Name** parameter. Effectively, the column name for the [Concatenated projection](/v1/docs/en/core-concat-projection) is therefore systematically composed from the default names for the concatenated projections. The literals contribute the complete **Literal**. --- Runtime example: placeName (state) Neukirchen (Oberösterreich) Neukirchen (Schleswig-Holstein) Neukirchen (Hessen) Neukirchen (Bayern) | ![images/download/attachments/78251658/image-2023-10-24_11-34-4-version-1-modificationdate-1698140056338-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image-2023-10-24_11-34-4-version-1-modificationdate-1698140056338-api-v2.png) | | --- | --- | ### Simple example: Write a number range value into the query result Each time a search is called, a unique string is generated via a [Number range value](/v1/docs/en/core-generated-number-range-value) resolver, which on one hand identifies the executing user ([User of session](/v1/docs/en/base-session-user-value)) via his ID (`id`) and on the other contains a "sequence number" for the query. Configuration: **NOTE:** In order for a [Literal projection](/v1/docs/en/core-literal-projection) to appear in the search result, a tuple or CSV search must be performed. In the example, we assume a CSV search for an unspecified entity. | The screenshot shows three **Projections** for the (CSV) search, the first of which – a [Literal projection](/v1/docs/en/core-literal-projection) – is shown expanded: - The **Name** parameter with the value "Search_ID" labels the column in the output (see below). - The *value configuration* for the **Literal** uses the [Number range value](/v1/docs/en/core-generated-number-range-value) resolver for the [Number range type](/v1/docs/en/core-number-range-type) "XF_SEARCH_CONTROL" set up for this purpose, in order to obtain a value once via this, which is assigned as a constant for the projection. The other projections with the (alias) names "Booking" and "Status" contain the actual payload of our request. | ![images/download/attachments/78251658/image-2023-10-24_11-37-33-version-1-modificationdate-1698140265362-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image-2023-10-24_11-37-33-version-1-modificationdate-1698140265362-api-v2.png) | | --- | --- | Runtime example: | First CSV search request | Subsequent CSV search request | | --- | --- | | Search_ID,Booking,Status USR:1901#QRY:1000007,RE01230858,NEW USR:1901#QRY:1000007,RE01230857,NEW USR:1901#QRY:1000007,RE01230856,NEW USR:1901#QRY:1000007,RE01230849,NEW USR:1901#QRY:1000007,RE01230846,NEW USR:1901#QRY:1000007,RE01230845,NEW USR:1901#QRY:1000007,RE01230841,NEW USR:1901#QRY:1000007,RE01000000,NEW | Search_ID,Booking,Status USR:1901#QRY:1000009,RE01230859,NEW USR:1901#QRY:1000009,RE01230858,NEW USR:1901#QRY:1000009,RE01230857,NEW USR:1901#QRY:1000009,RE01230856,REJECTED USR:1901#QRY:1000009,RE01230849,NEW USR:1901#QRY:1000009,RE01230846,NEW USR:1901#QRY:1000009,RE01230845,CONFIRMED USR:1901#QRY:1000009,RE01230841,NEW USR:1901#QRY:1000009,RE01000000,CONFIRMED | - The second run results in changed status values for some bookings and an additional new booking compared to the first one. ### Simple example: "Recoding" a Boolean value (e.g. to plain text) Fields with Boolean values can be used to binarily assign or deny qualitative characteristics to an entity. In a direct projection for such a field, a Boolean value (true/false) then appears in each case, without it being apparent when looking at an output line what this should actually mean. The "readability" of the data in a search result can then be increased by assigning a text identifier describing the presence or absence of the flagged feature instead of the Boolean value in each output line. In the following very simple case, the status of a user account (see [Users](/v1/docs/en/base-user)) is "recoded" as plain text using the "Active" (`active`) Boolean field in a projection, so that the text "ACTIVE" or "INACTIVE" appears. Configuration: **NOTE:** In order for a [Literal projection](/v1/docs/en/core-literal-projection) to appear in the search result, a tuple or CSV search must be performed. In the example, we assume a CSV search for the "User" (`User`) entity. | The screenshot shows two **Projections** for the output of a list of user accounts with a clear indication whether the respective account is active ("ACTIVE") or not ("INACTIVE"): - The first projection named "ACCOUNT_STATUS" uses a [Case projection](/v1/docs/en/core-case-projection) to evaluate the "Active" (`active`) Boolean field of the user account by a [Field restriction](/v1/docs/en/core-property-search), which is satisfied if the active field contains the value `true`. - If this is the case, a [Literal projection](/v1/docs/en/core-literal-projection) sets the `ACTIVE` static text value as a **Literal**. - Otherwise, another [Literal projection](/v1/docs/en/core-literal-projection) sets the `INACTIVE` static text value. - The second projection identifies the user account by name – by [Property projection](/v1/docs/en/core-property-projection) on the "username" (`username`) property. | ![images/download/attachments/78251658/image-2023-10-24_11-39-50-version-1-modificationdate-1698140402397-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image-2023-10-24_11-39-50-version-1-modificationdate-1698140402397-api-v2.png) | | --- | --- | Runtime example: | In the result of the CSV search, the ACCOUNT_STATUS column shows in an immediately understandable way whether the respective account is active or not. The output of true/false would only be understandable in connection with the column name. | ACCOUNT_STATUS,ACCOUNT_NAME ACTIVE,mjmartinez123 ACTIVE,jmustermann INACTIVE,jmmustermann INACTIVE,jdsmith0815 .... | | --- | --- | ### Special use: Literal projection as a check value in a field restriction Configuration: | The screenshot shows the configuration for the **Restriction** of a custom overview for [Companies/Clients](/v1/docs/en/base-company-account) accounts based on an OR operation of two instances of the [Field restriction](/v1/docs/en/core-property-search): - The first [Field restriction](/v1/docs/en/core-property-search) (left; collapsed) checks if the company metatype "Company" (`COMPANY`) is selected in the "Metatype" (`metaType`) field of the company. This criterion defines the restriction that should take effect for all roles *other* than the "Administrator" role. - The second [Field restriction](/v1/docs/en/core-property-search) (right; expanded) determines whether the [Role of session](/v1/docs/en/base-session-role-value) is the "Administrator" role. If this is the case, then the [Field restriction](/v1/docs/en/core-property-search) has a "easing" effect on the other criterion because of the OR conjunction, i.e. if an "administrator" is logged in, then the constraint for the "metatype" is effectively ignored. - As a *compare value* (right) within the [Field restriction](/v1/docs/en/core-property-search), a [Role](/v1/docs/en/base-role-value) value resolver can be used directly to define the "Administrator" role as a fixed value. - As a *check value* (left) within the [Field restriction](/v1/docs/en/core-property-search), on the other hand, only a *projection* can be considered for formal reasons. Here we use the [Literal projection](/v1/docs/en/core-literal-projection), in which the [Role of session](/v1/docs/en/base-session-role-value) resolver can be used. Since this returns an entity of the "Role" (`Role`) type, i.e. a complex data object, we still have to concatenate an [Object property](/v1/docs/en/core-property-resolver) resolver to get a simple fixed value (*here*: `Long`) from the "ID" (`id`) field which is suitable as a **Literal**. **NOTE:** As can be seen in the screenshot, we also explicitly resolve the "ID" field relevant for the comparison in the *compare* *value* (right) via an [Object property](/v1/docs/en/core-property-resolver) resolver, although the constraint would work without this thanks to an automatic type conversion (Entity → Long/id). | ![images/download/attachments/78251658/image-2023-10-24_11-42-52-version-1-modificationdate-1698140584585-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image-2023-10-24_11-42-52-version-1-modificationdate-1698140584585-api-v2.png) | | --- | --- | ALTERNATIVE configuration: | The configuration shown on the right solves the task equally but a bit more elegantly: - The first [Field restriction](/v1/docs/en/core-property-search) (left; collapsed) has been kept unchanged. - The second [Field restriction](/v1/docs/en/core-property-search) (right; expanded) again acts as an "exception rule", i.e. to neutralize the restriction for the "metatype" when an "administrator" is logged in: - We define the *check value* (left) again via a [Literal projection](/v1/docs/en/core-literal-projection). However, this time we obtain the Boolean return value of a [Role rule](/v1/docs/en/base-role-rule) via a [Rule value](/v1/docs/en/core-rule-value) resolver as the **Literal**. This is a considerable advantage at the latest when the "exception" applies to more than one role. - As a *compare value* (right) we need here only a value resolver for a static Boolean value `true` (see [Static values](/v1/docs/en/core-literal-value-resolver)). **NOTE:** Using the [Rule value](/v1/docs/en/core-rule-value) resolver, any rules can be included in the **Restriction** according to this scheme, which enables, among other things, access to [Association criteria](/v1/docs/en/core-association-criteria) as a [Sub criterion rule](/v1/docs/en/core-association-sub-criteria-rule). However, it must be taken into account that the return values of rules come into play this way only as constants, they cannot be applied to fields of the entity searched for or evaluated *in its context*. If, on the other hand, a [Property projection](/v1/docs/en/core-property-projection) returns a *check value* from a Boolean field of the entity searched for, for example, this can be contrasted with a Boolean *compare value* from a [Rule value](/v1/docs/en/core-rule-value) without this having to be "packed" (on the right-hand side in the comparison) into a [Literal projection](/v1/docs/en/core-literal-projection) for this purpose. | ![images/download/attachments/78251658/image-2023-10-24_11-41-13-version-1-modificationdate-1698140485846-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image-2023-10-24_11-41-13-version-1-modificationdate-1698140485846-api-v2.png) | | --- | --- |