Skip to main content Skip to complementary content

Generic object

Generic objects are structures for storing and interacting with data in an app. They are the primary type of entity through which the engine provides access to the components of an app. When the engine retrieves an app for the API, it converts the app to a JSON structure and returns a handle to be used for API interactions. The component objects of the app are turned into JSON generic objects. These generic objects are sub-objects of the app and cannot exist without it.

The Capability APIs, the Qlik Sense .NET SDK, and the enigma.js library all use the Qlik Engine JSON API internally, and so expose generic objects via their classes and methods.

The generic object is considered "generic" because it is a flexible structure that can represent many different app components, such as sheets, stories, lists, hypercubes, slides, and bookmarks. Generic objects can contain or refer to other generic objects, depending on their respective types. The qType property of the generic object identifies its type (for example, some possible values for qType are "sheet", "Dimension", "Measure", and "GenericObject").

Properties and layout

The generic object has two important components that we rely on during interactions with app data: a set of properties that defines the app’s structure and logic, and a layout that represents the engine’s evaluation of the definitions in the properties. We refer to this evaluation by the engine as "rendering". You can set the properties of a generic object by calling the SetProperties method in the Qlik Engine JSON API. You retrieve the layout of a generic object by calling the GetLayout method.

Validation states of generic objects

Unlike properties, layouts are not saved anywhere. They are calculated on the fly so that the client has the most up-to-date view of the data when it retrieves a layout. Because of this, the engine keeps track of data that has changed between calls to GetLayout. The generic object can have one of three states:

  • Invalid: Something relating to the object's data has changed. Either the data model has changed (typically because a selection has been made) or a property has been updated by a call to the SetProperties method.
  • Validating: An object is invalid and the GetLayout method has been called. The validation process starts.
  • Valid: The validation of the object has finished. The engine returns the layout requested by the GetLayout method.
When you make a call to the engine that changes the layout (for example, filtering or selecting data), the engine returns a field in the response called change. This field contains the handles of the objects that have changed since the last layout calculation. At this point, you should call GetLayout to get the latest view of the data.

Example: properties and layout

Consider the following set of properties of a generic object:

{
    "qInfo": {
        "qType": "simple-object",
        "qId": "12345"
    },
    "myClientProperty": "This is just a string that engine will persist in my app",
    "salesString": {
        "qStringExpression": {  // This will evaluate to a formatted string.
            "qExpr": "Sum(Sales)"
        }
    },
    "salesValue": {
        "qValueExpression": {  // Same as above but will evaluate as number.
        "qExpr": "Sum(Sales)"
        }
    }
}

When the client calls the GetLayout method, the engine evaluates the properties and returns the following layout:


{
    "qInfo": {
        "qId": "12345",
        "qType": "simple-object"
    },
    "qSelectionInfo": {},
    "myClientProperty": "This is just a string that engine will persist in my app",
    "salesString": "198.22",
    "salesValue": 198.221456
}

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!