Sub search

Restrictions – Abstract

Purpose: As a restriction, a Sub search checks whether at least one instance exists for the selected Entity that fulfills the configured Where condition.

images/download/attachments/162410478/image-2024-1-3_10-18-39-version-1-modificationdate-1704273519209-api-v2.png

As a restriction, a Sub search checks whether at least one instance exists for the selected Entity that fulfills the configured Where condition.

  • In the same way as the Subsearch projection, a Tuple search can be formally configured with a single Projection, which can also contain Joins and criteria for a Group by.

    • Projections within the Sub search primarily refer to the Entity selected for the Sub search as the data source.

    • The _parentQuery prefix enables references to the parent search. It can be cascaded if required (_parentQuery._parentQuery.[...]) to address a specific level of a multi-level hierarchy.

  • In contrast to a Subsearch projection, however, the Sub search, like all other Restrictions, only returns a Boolean return value and does not provide any details about the search result or the value of any configured Projection:

    • The return value is true if at least one instance exists for the Entity that fulfills the Where condition.

    • The return value is false if no instance exists for the Entity that fulfills the Where condition


IMPORTANT◄ The Sub search ignores access restrictions. It considers all instances of the selected Entity regardless of ownership, participation or Company authorizations.


Configuration

Parameter

Type

Description

Entity

Entity type

The selection for the Entity parameter determines the primary data source for the Sub search. Only the entity types offered in the dropdown can be selected.

Entity types that are not directly available as an 'Entity' in the parent search (e.g. attributes) can also be selected for a Sub search.

NOTE◄ Additional data sources can optionally be integrated into the Sub search via Joins.

Projection

Projection

The configuration of a Projection can be dispensed with, as only the existence of a "result line" is decisive for the Sub search as a restriction.

  • If no Projection is defined, the Sub search is implemented in the database (in the EXISTS condition) with the static Long value 1 as the only projection.

Joins

Join

Additional data sources can be added to the Sub search via Joins, which are then available for Projektionen in other areas within the Sub search.

Where

Restriction

The Where parameter enables the configuration of Restrictions for the acceptance of instances of the Entity within the Sub search.

  • The prefix _parentQuery in property paths of the configuration refers – if necessary – to the entity from the parent search.

  • Property paths without this prefix refer to the context given in the Sub search, i.e. either to properties of the Entity or paths to properties of other entities integrated via Joins.

IMPORTANT◄ If the configuration of a Where condition is completely omitted in the context of a Sub search, then the Sub search is completely ignored when compiling the database query.
If required, a pro forma configured result-neutral Where condition (e.g. id > 0) ensures that a Sub search is executed, which should either refer to all instances of the Entity or whose restrictive effect is based on non-optional Joins.

Group by

Projection

The configuration of criteria for a Group by does not generally represent any added value for the effect of a Sub search as a restriction, as this only checks the existence of at least one result row.

Examples

Simple use case: Recognize orphaned weak references

A 'weak reference' is a reference to entities whose existence is not considered an obstacle to the deletion of the entity in question.

For example, all entities use a 'weak reference' to refer to the ID (id) of a company account via the 'owner' (ownerId) property. A company account that 'owns' other entities can therefore be deleted without the owned entities first having to be assigned to a new owner.

A Search should list Users for whom the company account referenced as 'owner' (ownerId) no longer exists.

Configuration:

In a Search for Users, the Where condition is configured as an AND conjunction as shown on the right:

  • The Field restriction uses a compare (>0) to check whether an 'owner' is even specified for the user account.

    NOTE◄ For entities without an owner, the value -1 appears in the ownerId property.

  • Like the 'owner' property, the Sub search below refers to the 'Company account' (CompanyAccount) Entity.

    • A Projection, Joins and criteria for Group by are not required.

    • The Where condition uses another instance of the Field restriction to check for a match (==) between the ownerId property of the user account from the parent search (_parentQuery) and the 'ID' (id) property.

  • The Sub search has been 'negated' here, which is indicated by the symbol (!) at the bottom of the Search junction automatically added as a result.

Effectively, the Where condition of the parent search is passed if the 'owner' property of the user account specifies an ID for which the Sub search does not find a match among all company accounts. As the Sub search ignores any access restrictions, this implies that the company account referenced as the 'owner' does not exist (anymore).

images/download/attachments/162410478/image-2024-1-3_10-22-38-version-1-modificationdate-1704273758662-api-v2.png

Typical use case: Incoming reference(s) as a restriction

A custom overview (see Custom overviews) should only list those Users to whom at least one document (see Documents) with the Document type 'CV' (CV) is assigned.

NOTE◄ Assigned Documents refer to the 'referenced object' and not vice versa (see Assigning documents). Therefore, the properties of all Documents relevant for the reference must be evaluated in order to identify 'assigned documents'.

Configuration:

A Sub search is configured as a Restriction for the custom overview as shown on the right:

  • The 'Document' (Document) entity type is selected as the Entity to be evaluated for the Sub search, which is only available if the associated module is installed and licensed.

  • As a Where condition, several instances of the Field restriction must be checked within an AND conjunction in order to determine whether the document to be evaluated is assigned to the user account from the parent search (here: the implicitly generated Tuple search for the custom overview). Details on the Search junction can be seen below.

    • The 'Referenced object' (referencedEntity) property must refer to the 'User' Class.

    • The 'Referenced entity ID' (referencedEntity) property must specify the ID of the user account from the parent search (_parentQuery.id).

    • The 'Reference status' (referenceStatus) property must specify the status 'Referenced' (REFERENCED).

    • The 'Document type' (documentType) property must specify the user-defined Document type 'Curriculum vitae' (CV).

images/download/attachments/162410478/image-2024-1-3_10-27-31-version-1-modificationdate-1704274051404-api-v2.png

images/download/attachments/162410478/image-2024-1-3_10-28-3-version-1-modificationdate-1704274084054-api-v2.png

NOTE◄ If access restrictions are effective in the execution context, the custom overview only takes into account Users for whom read access is granted. Accordingly, the incoming references of documents are only checked for these users. Whether there is access to the 'qualifying' CV document in the execution context is not decisive, as the Sub search ignores access restrictions. The overview may therefore also show user accounts for whose 'CV' document there is no read access.

Special use case: Identifying duplicates

A Search should list all Company accounts whose address uses an 'account number' (address.accNumber) that is 'ambiguous' – i.e. also assigned to at least one other company.

Configuration:

Within a Search for Company accounts, a Sub search is configured as the only restriction in the Where condition, as shown on the right:

  • Like the parent Search, the Sub search also refers to the Entity 'CompanyAccount' (CompanyAccount).

  • The configuration of a Projection is not required.

  • Joins are not required.

  • The Where condition of the Sub search uses an AND conjunction with two instances of the Field restriction type, each of which compares a property of the company checked by the Sub search with the same property of the company in the parent Search (_parentQuery)

    • The first Field restriction requires a match (==)) for the address property 'Account number' (address.accNumber)

    • The second Field restriction also requires a difference for the 'ID' (id) property.

  • Criteria for Group by are not required.


NOTE

  • In this case, the parent search and the Sub search exceptionally relate to the same Entity. Typically, the Sub search evaluates a different entity type than the parent search.

  • The fact that both levels of the search relate to the same entity type illustrates the following important difference with regard to access rights to companies:

    • The parent Search only takes into account Company accounts that can be accessed in the execution context. The Sub search is therefore only executed for this subset of all Company accounts.

    • However, the Sub search compares the Company accounts in the subset determined by the possibly restricted access in the parent Search with all Company accounts without taking access restrictions into account in order to search for another company that uses the same account number as the one from the subset.

images/download/attachments/162410478/image-2024-1-3_10-32-30-version-1-modificationdate-1704274350943-api-v2.png

NOTE◄ In an execution context with effective access restrictions, the Search returns all Firme whose 'account number' is assigned ambiguously AND for which read access exists. Therefore, the search result does not necessarily always show all Company accounts that refer to the same ambiguously assigned account number, but only those for which read access also exists in the execution context. Overlaps between the account numbers of Company accounts for which there is no read access in the execution context are not evaluated