FIND

This action finds particular instances of a business object(s) in the system. There are several variations of the action:

  1. FIND ALL Id()

    where Id() indicates the name of the business object. The action written in this form will find all the existing instances of the specified business object. For example,
    FIND ALL Account 
  2. FIND (Id() | StringLiteral())

    where Id() or StringLiteral() indicate the name of the query to run. For example,
    FIND 'Open accounts'  

    this action will run a query named ‘Open accounts’. Note that the apostrophe must only be used if the query name contains space symbols otherwise the identifier of the query name can be used without the apostrophe.

  3. FIND Id() WHERE RuleCondition()

    where Id() indicates the name of a business object. The action written in this format will find all instances of the business object that match the specified condition. For example,
    FIND Account WHERE Account.State = 'Open' 

The following constructs can be optionally used after the FIND action (written in any of the above formats):

  1. ORDER BY AttributeIdentifier() (ASC | DESC)

    If this construct is used after the FIND action, the instances found by the action will be sorted by the specified attribute in the specified order. AttributeIdentifier indicates the attribute of the business object on which the sorting will be performed. The ASC keyword indicates the ascending order and the DESC keyword indicates the descending order. For example,
    FIND ALL Account ORDER BY Account.Balance  

    finds all accounts sorted by their balances in the ascending order. If ASC and DESC keywords are omitted the ASC keyword is implied.

  2. TAKE BEST (IntegerLiteral() | AttributeIdentifier())

    If this construct is used after the FIND action, only the specified number of business object instances which match the specified criteria, will be found by the action. Typically this construct is used together with the ORDER BY keyword. For example,
    FIND ALL Account ORDER BY Account.Balance DESC TAKE BEST 5  

    this action will find 5 accounts with the highest balance.

  3. IN BATCHES OF IntegerLiteral()

    If the action is likely to find many instances of the business object (hundreds or even thousands) their processing may take a while. In this case it is better to perform processing of instances in smaller chunks (batches). After processing of each batch is finished the results will be immediately committed to the system and stored in the database. If the batch size is not specified the system will only commit the results once all the instances have been processed. For example:
    FIND Account WHERE Account.State = 'OPEN' AND Account.Balance > 1000 ORDER BY Account.Balance IN BATCHES OF 5 

    Perform some actions with found objects (The actions will be performed in batches of 5 objects)

    If IN BATCHES OF keyword is omitted the default batch size of 1000 is used. See also the “Batch Operations” section.

  4. LIMIT ArithmeticExpression() , ArithmeticExpression()

    If this construct is used after the FIND action, only the specified rows will be returned. The first parameter indicates the first row number to be returned (starting from 1) and the second parameter indicates the number of rows to be returned. For example:
    FIND Account WHERE Account.State = 'OPEN' AND Account.Balance > 1000 LIMIT 20,3 

    This will return 3 rows starting from row 20.

  • Last modified: 2023/05/09 01:37