Filter Expression Syntax

If an invalid filter expression is specified on the Events Filter Selection page, an error message is displayed when you attempt to activate the integration. You must correct the filter expression to activate the integration.

Note the following event filter expression syntax guidelines:

  • The filter expression must be specified as a single string.
  • The filter expression must evaluate as a boolean expression.
  • The filter expression must contain one or more comparison statements.
  • Comparison statements must be specified in the following order:
    field operator value

    For example:

    activityDetails.activityType == 'Install'

    Specifying a different order is not allowed.

    • Comparing field to field (A == B) or value to value (1 == 1) is not valid.
    • A field must be an alphanumeric identifier with no spaces or special characters except an underscore. Subfields are separated by a dot (.). For example:
      • activityDetails.activityType
      • activityDetails.X_MYPROP_10
      • field.subField
    • Supported comparison operators are:
      • <
      • >
      • <=
      • >=
      • ==
      • !=
      • in
    • The value can be either a string literal, an integer literal, or an array literal of strings and integers.
      • String literals are delimited by single quotes with an escape character (~). For example:
        • str == 'My String'
        • str == 'My string with ~' a quote inside'
      • Integer literals are specified without quotes, cannot contain dots, and cannot contain leading zeroes.
        • num == 0
        • num == 12345
        • num == -67/li>
      • Array literals must only contain strings or only integers, and are in square brackets. Empty arrays are not allowed. Arrays are only allowed following the in operator.
        • enum in [1,2,3]
        • enum in ['Abc','Def','Ghi']
    • String comparisons are valid:
      • date > '2015-06-02'
    • String comparisons are all case insensitive:
      • name == 'john.smith'
      • name == 'JOHN.SMITH'
    • String-integer coercion occurs:
      • num == -123
      • num == '-123'
  • Multiple comparison statements must be separated by a logical and/or operator.
    • A == 1 and B == 2 or C == 3
    • A == 'xx' or A == 'yy'
  • Operator precedence is as follows:
    • comparison operators: ==, !=, <, >, <=, >=, in
    • 'not'
    • 'and', 'or'
  • Logical operators (and/ or) have the same precedence. Therefore, use parentheses to achieve precedence:
    • A == 1 and (B == 2 or C == 3)
  • Operators are also case insensitive:
    • (num IN [1,2,3]) OR (num < 0)
  • Any statement can be preceded by a not operator to negate it.
    • not (activityType in ['IN','TC','BR'])
    • A == 1 and not ( B == 2 or B == 3 )
  • Whitespace that is outside strings is ignored.
  • When the field being compared does not exist in the event or is null, it evaluates to an empty string. For example, the expressions (non_existent_field == '') and (null_field == '') are both true.

Activity Event Fields

The activity event contains the following fields:

  • eventType: The type of the event, such as activityCreated, activityUpdated, and so on.
  • applicationId: The ID of the application that performed the operation that generated the event. It is only present if the operation was performed by an application.
  • time: The time of the event in the UTC time standard (string). The time format is YYYY-MM-DD HH:MM:SS.
  • user: The user who performed this event (string).
  • activityDetails: A record containing the following activity-related key fields:
    • activityId: The identifier of the activity (integer). This is a mandatory field.
    • resourceId: The identifier of the resource to which the activity is assigned (string). This is a mandatory field. The field maps to the external_id field.
    • date: The date the activity is scheduled in the format YYYY-MM-DD. If the activity is not scheduled, the value is NULL.
    • apptNumber: This field is used by integrations to hold the external ID of the activity. The external ID is the identifier of the activity in the origin system. This is an optional field.
    • customerNumber: This field is used by integrations to hold the external ID of the account. The external ID is the identifier of the account in the origin system. This is an optional field.
  • activityChanges: The list of resource fields that changed with the event. The fields have the same types and values as used in the GET, POST, and PATCH operations with a few exceptions. The time fields are in UTC.

Example for Activity Event Filter Expression

(activityDetails.activityType in ['IN','TC','BR']) AND (user != 'my_integ') 
AND (activityDetails.customerName != '')

Inventory Event Fields

The inventory event contains the following fields:

  • eventType: The type of the event, such as customerInventoryUpdated, customerInventoryDeleted, resourceInventoryCreated, and so on.
  • applicationId: The ID of the application that performed the operation that generated the event. It is only present if the operation was performed by an application.
  • time: The time of the event in the UTC time standard (string). The time format is YYYY-MM-DD HH:MM:SS.
  • user: The user who performed this event (string).
  • activityDetails: A record containing the following activity-related key fields:
    • activityId: The identifier of the activity (integer). This is a mandatory field.
    • resourceId: The identifier of the resource to which the activity is assigned (string). This is a mandatory field. The field maps to the external_id field.
    • date: The date the activity is scheduled in the format YYYY-MM-DD. If the activity is not scheduled, the value is NULL.
    • apptNumber: This field is used by integrations to hold the external ID of the activity. The external ID is the identifier of the activity in the origin system. This is an optional field.
    • customerNumber: This field is used by integrations to hold the external ID of the account. The external ID is the identifier of the account in the origin system. This is an optional field.
  • inventoryDetails: A record containing the following inventory-related key fields:
    • inventoryId: The identifier of the inventory (integer). This is a mandatory field.
    • inventoryType: One of the inventory types defined in the Configuration > Inventory types page in the Field Service Manage interface.
    • status: The status, such as customer, resource, installed, and deinstalled.
  • inventoryChanges: A record containing the following inventory changed fields:
    • inventoryId
    • status
    • inventoryType
    • serialNumber
    • quantity
    • exchangedInventoryId
    • resourceId
    • activityId
    • All the custom properties of an inventory, except file properties.
  • exchanged: The value is true when an inventory is created as part of the exchange operation. The eventType is inventoryInstalled or inventoryDeinstalled. The field is empty when the value is false.

Example for inventory event filter expression

(activityDetails.activityType in ['IN','TC','BR']) AND (user != 'my_integ') AND (activityDetails.customerName != '') 
AND (inventoryDetails.inventoryId == 1000)