Skip to main content

FieldLogs

Enterprise Object Data

The Enterprise Object Data Instructions allow manipulation of Object data.

This category includes five Fieldlogs Specific Script Instructions:

  1. Flkw:GetObjectValue

  2. Flkw:SetObjectValue

  3. Flkw:DefineObject

  4. Flkw:BindObject

  5. Flkw:SelectObjects

Important

In order to use these functions, the Template variables of type Object must be created and available at runtime. To know more about Template variables, click here.

These Instructions manipulate the value of the selected Properties of the selected Object inside those objectModel variables.

Flkw:GetObjectValue retrieves the value of a property in an Object variable.

Format: Flkw:GetObjectValue( 'Object Variable.property name');

Parameters

Description

Object variable.property name

The name of the Object variable and the name of the property whose value is to be retrieved.

To construct an enhanced Script Instruction using Flkw:GetObjectValue:

  • Select JS Execute from the Instruction dropdown list. In the Expression field, enter the Flkw:GetObjectValue Instruction as shown.

    GetObjVal1.png

The Flkw:GetObjectValue Instruction is added to the Script.

GetObjVal2.png

At runtime, the Script gets the value of the property in the Object variable and stores it in a Local Variable. The Script displays the values as shown below.

GetObjVal3.png

Flkw:SetObjectValue sets the value of a property in an Object variable.

Format: Flkw:SetObjectValue('Object variable.property name','Value');

Parameters

Description

Object variable.property name

The name of the Object variable and the name of the property whose value is to be set.

Value

The value to be set.

To construct an enhanced Script Instruction using Flkw:SetObjectValue:

  • Select JS Execute from the Instruction dropdown list. In the Expression field, enter the  Flkw:SetObjectValue Instruction as shown.

    SetObjVal1.png

The  Flkw:SetObjectValue Instruction is added to the Script.

At runtime, the initial value (1200) of the property (BatteryVoltage) of the Object Variable(BatteryObj) is displayed in Step 3.

SetObjVal2.png

The Script sets the new value (9900) to the property (BatteryVoltage) of the Object Variable(BatteryObj) . Immediately, the new value is displayed in Step 3 as shown below.

SetObjVal3.png

Flkw:DefineObject creates a variable to hold an instance of an Object, so that it can be used in the Script.

These variables are used when the Script requires a local Object Variable to hold values and manipulate them. These variables will not be visible anywhere else in the Template, unlike Template Variables.

Format: Flkw:DefineObject('Variable Name','Description','Object Name');

Parameters

Description

Variable Name

The name of the variable.

Description

The description of the variable

Object Name

The name of the Object whose instance is held by the variable

To construct an enhanced Script Instruction using Flkw:DefineObject:

  • Select JS Execute from the Instruction dropdown list. In the Expression field, enter the Flkw:DefineObject Instruction as shown.

    DefineObj1.png

The Flkw:DefineObject Instruction is added to the Script. The user enters a BatteryID.

DefineObj4.png

This is assigned to the property (BatteryID) of the local Object Variable within the Script and displayed as shown below.

DefineObj3.png

Flkw:BindObject binds the content of a JavaScript object to a Template Variable.

For example, a JSON stream containing data or a response from an external call can be parsed into a JavaScript Object. Then, using Flkw:BindObject, you can bind the JavaScript Object to a Template variable for further use in the Template execution.

Format:Flkw:BindObject('window.Objectname','Template variable name');

Parameters

Description

window.Objectname

The name of the Object

Note

The Object should always be named as window.Objectname to ensure that changes to any properties of the object are reflected

Template variable name

The name of the template variable to bind to the defined Object. This can either be a Template variable or an Object variable defined by Flkw:DefineObject

To construct an enhanced Script Instruction using Flkw:BindObject:

  • Select JS Execute from the Instruction dropdown list. In the Expression field, enter the  Flkw:BindObject Instruction as shown.

    BindObj1.png

The  Flkw:BindObject Instruction is added to the Script.

Flkw:SelectObjects returns the rows from an Object that satisfy the query.

Format: Flkw:SelectObjects('Object name', 'Property query');

Parameters

Description

Object name

The name of the Object that contains the value that you want to display.

Property query

The basic 'Select' query that specifies conditions to select a subset of the Object.

The property query may consist of one or more conditions.

Conditions can be combined with logical operators ( && and ||) and grouping (parenthesis).

The format of the Property query is:

" .property name operators (==,<,>) property value"

For example: " .BatteryID == 'A124' "

To construct an enhanced Script Instruction using Flkw:SelectObjects:

  • Select JS Execute from the Instruction dropdown list. In the Expression field, enter the Flkw:SelectObjects Instruction as shown.

    SelectObjects1.png

The Flkw:SelectObjects Instruction queries the Object and returns the rows corresponding to the condition BatteryID == 'A124' as a list. The Script then extracts the required BatteryVoltage value and displays it as shown below.

SelectObj2.png