Developer

Additional Offline OData Features

There are some additional offline OData features.

  • sap.entityexists

    A built-in function that can be used in a $filter system query option to check for the existence of a related entity.

    sap.entityexists takes a single parameter that is a navigation path.

    In the following example, each Order has a relationship to a SalesRep, and each Order either has an assigned SalesRep or it does not.

    To get all Orders that have an associated SalesRep:
    Orders?$filter=sap.entityexists( SalesRep )
    To get all Orders that do not have an associated SalesRep:
    Orders?$filter=not sap.entityexists( SalesRep )
  • Prefer header
    Only max page size can be specified for the Prefer header:
    odata.maxpagesize=<number greater than 0>
  • EventLog entity set

    A local-only entity set for the OfflineOData namespace that allows applications to view a log of past system events.

    Event entities can be queried from the EventLog entityset by making a GET request to /EventLog. This is a read-only entity set and any attempts to modify it results in an error. Only the most recent 100 events are available from the log.

    The following types of system events are logged:
    • Refresh Records a successful refresh. Has a Type of refresh and the Details section contains the refresh subset string used, or null if it was a full refresh.
    • Flush Records a successful flush. Has a Type of flush and the Details section is always null.
    //Sample Event entities schema
    Properties: [
               {
                        Name: "ID",
                        Type: "Edm.Int64",
                        IsNullable: "false",
                    },
                    {
                        Name: "Type",
                        Type: "Edm.String",
                        IsNullable: "false",
                        MaxLength: "128",
                    },
                    {
                        Name: "Time",
                        Type: "Edm.DateTimeOffset",
                        IsNullable: "false",
                    },
                    {
                        Name: "Details",
                        Type: "Edm.String",
                        IsNullable: "true",
                        MaxLength: "2048",
                    },
    
    Example queries that can be made against the entity set:
    • Retrieve the details of the last full refresh
      GET /EventLog?$filter=Type eq ‘Refresh’ and Details eq null&$top=1&$orderby=Time desc
    • Retrieve the details of the last refresh for a particular defining request
      GET /EventLog?$filter=Type eq ‘Refresh’ and (Details eq null or indexof(Details, ‘req1’) ge 0)&$top=1&$orderby=Time desc
    • Retrieve the times of the last 10 flushes
      Get /EventLog?$filter=Type eq ‘Flush’&$top=10&$select=Time&$orderby=Time desc
  • Lambda Operators

    Offline OData supports the two OData version 4 lambda operators, any and all. Lambda operators allow an arbitrary Boolean expression to be evaluated on a related collection. That is, lambda operators allow the results of a query to be filtered based on a collection of related entities.

    Both lambda operators are prefixed with a navigation property path that identifies a collection.

    The argument of a lambda operator is a lambda variable name followed by a colon (:) and a Boolean expression that uses the lambda variable name to refer to properties of the related entities identified by the navigation path.

    The any operator returns true if the Boolean expression evaluates to true for any member of the collection. The following example returns all Customers that have at least one order purchased in the Eastern region:
    Customers?$filter=Orders/any(d:d/Region eq ’Eastern’)
    The all operator returns true if the Boolean expression evaluates to true for all members of the collection. The all operator returns true if the collection is empty. The following example returns all Customers that purchased all their orders in the Eastern region:
    Customers?$filter=Orders/any(d:d/Region eq ’Eastern’)
  • getRequestQueueIsEmpty method

    The offline store provides the getRequestQueueIsEmpty method to determine if the request queue is empty. See the OData Offline APIs.