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.

The generic object is considered "generic" because it is a flexible structure that can be used to represent many different types of app components, such as sheets, stories, lists, slides, visualizations, and so on. 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.

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.

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: Some 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 information help you?

Thanks for letting us know. Is there anything you'd like to tell us about this topic?

Can you tell us why it did not help you and how we can improve it?