Skip to content

Target Path

This document describes target paths, the currently supported segments they're composed of, and how they can be used.

Overview

Target paths are strings which are interpreted at runtime. A target path is composed of segments which are resolved one after the other, with the result of one being used for the evaluation of the next. The result of the last segment is also the result of the target path. Each of these results (or "contexts") has two pieces of information: a data binding and, if appropriate, an associated UI element. Target paths are often used in metadata to retrieve a data binding that already exists somewhere in the app, but may also be used in rules to access data bindings or UI elements.

Design

A target path is built up using segments. Segments are separated by a slash (/) and generally have the following form:

#SegmentName:ParameterValue

Here, SegmentName specifies which segment should be used and ParameterValue is a custom value that's passed to it. Parameters are only used by some segments.

As mentioned above, segments take a context as their input, and pass the resulting context to the next segment. The starting context for a target path will often be either the current page or the current control, depending on where the target path is used.

If inside a segment the name or any other value of an object contains a slash (/), it must be escaped with two slashes (//).

Available Segments

  • #First - Returns the first item. Only valid if the current context is a list control or an array.
  • #Last - Returns the last item. Only valid if the current context is a list control or an array.
  • #Application - Returns the context of current application. UserId and DeviceId are stored in its ClientData object.
  • #Page:PageName - Returns the page with name PageName.
  • #Page:-Previous - Returns the page that comes before the current page on the stack. These can be chained with other Page segments.
  • #Control:ControlName - Returns the control with name ControlName. Only valid if the current context is a page.
  • #Value - Returns the value of a control. Only valid if the current context is a control.
  • #SelectedRow - Returns the index of the current selection. Only valid if the current context is a list control.
  • #SelectedTarget - Returns the data for the current selection. Only valid if the current context is a list control.
  • #Count - Returns the count. Only valid if the current context is a list control or an array.
  • #ClientData - Returns the ClientData object associated with the current context. This may be modified in a rule to provide easy access to custom data. Only valid if the current context has a UI element, for example, a control or a page. See also the getClientData method of the IClientAPI interface.
  • #ActionResult:ActionResultName - Returns the ActionResult object associated with the name.

Optional Segments

  • #Index:IndexNumber - Returns the item specified by IndexNumber. Only valid if the current context is a list control or an array. This is optional, by default, only defining the index number is sufficient.
  • #Property:PropertyName - Returns the property with name PropertyName. Only valid if the current context is an object. This is optional, by default, only defining the property name is sufficient.

Note

If your application is targeting mobile development kit 4.2 or older, using segment #Index:IndexNumber is mandatory for array index and #Property:PropertyName is mandatory for property name.

Targeting a Page

This target path returns the page with name "WorkOrderDetails".

  • #Page:WorkOrderDetails -> Returns a page with a specific name.

Targeting a Control

To get a control from the "WorkOrderDetails" page:

  • #Page:WorkOrderDetails/#Control:ControlName

To get the same control when the target path's context is the "WorkOrderDetails" page:

  • #Control:ControlName

To get the same control when the context is a page that was navigated to from the "WorkOrderDetails" page:

  • #Page:-Previous/#Control:ControlName

Targeting the Value of a Control

To get the value of a control on a specified page:

  • #Page:PageName/#Control:ControlName/#Value

Targeting Items in a List

The following target paths can be evaluated from a page which has a list picker control with name "ListPicker".

  • #Control:ListPicker/#Value/#First -> Returns the first item in the control.
  • #Control:ListPicker/#Value/#Last -> Returns the last item in the control.
  • #Control:ListPicker/#Value/5 -> Returns the 5th item in the control.
  • #Control:ListPicker/#Value/5/DisplayValue -> Returns the DisplayValue property from the 5th item in the control.
  • #Control:ListPicker/#SelectedTarget -> Returns the data associated with the currently selected list item.
  • #Control:ListPicker/#SelectedRow -> Returns the currently selected rows index.
  • #Control:ListPicker/#SelectedValue -> Returns the selected value (ReturnValue) associated with the currently selected item from the ListPicker control (FormCell.ListPicker).

Targeting Properties on Application's ClientData Object

  • #Application/#ClientData/UserId -> Returns the UserId of current user.
  • #Application/#ClientData/DeviceId -> Returns the DeviceId of current device.
  • #Application/#ClientData/MobileServiceEndpoint -> Returns the Endpoint URL of application in Mobile Services on SAP Cloud Platform.
  • #Application/#ClientData/MobileServiceAppId -> Returns the App ID of application in Mobile Services on SAP Cloud Platform.

Targeting Properties on a Page's ClientData Object

The following target path can be evaluated from a page whose ClientData object has an items property which is an array.

  • #ClientData/items/#First -> Returns a the first item in the items property of ClientData.

Targeting the Result Property in an ActionResult Object

The following target path can be evaluated while in an action chain having a previous action save off an ActionResult named 'CreateWorkOrder'.

  • #ActionResults:CreateWorkOrder/data/OrderDescription", -> Returns the result's OrderDescription.

Last update: September 29, 2020