When you use an app or service, data is stored and manipulated using objects. An object is an instance of an object class, containing data that adheres to a defined structure. An object typically represents a single real world object like a customer, order, or order line. If you're familiar with databases, an object can be thought of as a row in a database table.

Objects are accessed via data sources and created, read, updated, and deleted using dedicated action nodes. The individual values stored in objects are accessed and updated by binding them to properties in action nodes and UI components.

When developing there are cases where you need to be able to identify a single object, or a selection of objects, within a data source. To achieve that there are two concepts which are used individually and together: Object in context and Object selection. These two concepts enable you to explicitly state which object(s) to reference to when switching between UI and logic.

Example: Navigating from a list to details view

You have a view in your user interface with a List component bound to a data source called Events. To display the events, the list iterates through each object in the data source and can then for example display the name of that event. You'd like to be able to click on an item in the list and navigate to a new view displaying the details of that event. To do this, you'll need to use both the object in context and a selected object.

In an action connected to the On Item Click event handler of the list, you need to add a Set selection action node with the Selection Type property set to Object in context. When the action is triggered by clicking on a list item, it's in the context of that single item, and the action automatically knows which object was clicked on – this is the object in context. The Set selection action node then sets the Is Selected property of that object to true.

Next, you can add a Navigate action node to show the details view.

The details view can be configured with Text components that are bound to properties in the events data source. If a single object is selected when the view is loaded, that data in that object will be shown in the view

Example: When object in context and object selection clash

You have a List component bound to a data source called Projects. For each item, you have a Copy project button that triggers an action to create a new project and set it as selected.

Clicking Copy project on Project 1 will create Project 2 in the same data source. There is one object in context (Project 1) and one selected object (Project 2)

If you then try to create a Task object with Task.Project set to Projects (context/selected) the object in context, Project 1, will be assigned.

To have Project 2 assigned, you could use a function and add the Projects data source as a function parameter with Selection set to Selected object(s).

Good to know

  • If object in context and object selection ever come into conflict, the object in context will be used.

  • If you add an enum data source, object in context and object selection will also apply to those enums.

Object in context

The object in context is the current object being processed in an iteration. This allows you to loop through a many-cardinality data source and reference the properties as though it contained a single object to display or modify the data inside. The following elements run iterations and produce an object in context.

  • List and Table components These components have built-in iterators that loop through the data source they are bound to. The object in each list item or table row is the object in context.

  • Iterating containers in the UI A container can be configured to iterate over a multi-cardinality data source. The contents of the container will be repeated for each object in the data source (subject to any filters). The object in each iteration is the object in context. For example, you have an iterating container bound to a data source called Events, and a child Text component bound to Events.Title to list the name of every event.

  • Foreach action node When the foreach loops through the objects in a data source, the action nodes placed inside the foreach will be run for each object, with each object taking a turn being the object in context. For example, you have a foreach iterating over a data source called Event Attendees and inside the foreach a Send email action node with the recipient bound to the Event Attendees.Email property, to send a ticket by email to each attendee.

Object selection

An object in a many-cardinality data source can be selected. All objects in many-cardinality data sources have the built-in property Is Selected to track this flag. Any number of objects in a data source can be selected at the same time.

Object selection can be used to create a dynamic subset of objects in a data source or to select a single object. For example, you have a data source called Events and you create a view with Text components bound to the properties Events.Title and Events.Date. If you select a single object before navigating to the view, that object (event) will be used to populate the Text components.

This property, and its opposite Is Not Selected, can be referenced in a number of situations:

Data sources with selected objects are highlighted in the App data panel of the developer tools with a green tag. When a data source is selected, the number of selected objects is displayed above the table of objects and each selected object is marked with a check in the first column.

Last updated