sfGetValue

Returns the value of a form control.

Syntax

sfGetValue(id, index, propertyName, callback)

Parameters

Name

Type

Mandatory

Description

Name

Type

Mandatory

Description

id

string

yes

Control id of the form control.

index

number

no

Index of the form control. Applicable only if the control is present inside a group control.

The index is a zero-based index.

propertyName

string

no

Name of the property of the dataset item linked to the item selected in the form field. Applicable only to the form controls that can be bound to datasets. See dataset bound form controls.

callback

function

no

Code block to be executed after obtaining the value from the form field.

The callback function contains one parameter:

  • imageStream: binary stream of the image in the image or signature control

Applicable only to Image and Signature controls. See callback function.

Applies to

Control type

Applicable

Remarks/Exceptions

Control type

Applicable

Remarks/Exceptions

Input controls

Yes

 

Layout controls

No

 

Behaviour controls

No

 

Static information controls

Yes

Applies to Bar/QR code show only.

Value returned by the function differs with the form control. See values returned by form controls.

Usage examples

Example 1

Let us assume a form contains a text field TankNumber. The value of the text field can be obtained using,

sfGetValue('control_tanknumber')

Example 2

Let us assume a form contains a group control QuestionsChecklist with a numeric field CapacityInLitres. The value of the numeric field in the second row can be obtained using,

sfGetValue('control_capacityinlitres',1)

Here, because the field CapacityInLitres can exist multiple times i.e. for once per row in the group control, it is required to provide the index to refer to the exact field.

Example 3

Let us assume a form contains a selectbox control Terminal that displays the list of terminals from a dataset Terminals. The dataset has two properties TerminalName and ContactNumber, in addition to Code that is the default property available to all dataset items.

The selectbox displays TerminalName in the dropdown. When a user selects a terminal, the Code of the selected terminal is set as the value. So,

sfGetValue('control_terminal')

returns the Code of the selected item (terminal).

To obtain the contact number of the selected terminal, the name of the property can be passed as,

The index is set to 0 because the selectbox in our example is not inside a group control.

Example 4

Let us assume a form contains an image field FuelPumpSnapshot. The image in the field can be obtained using,

The image data stream is available as a parameter in the callback function.

Return value formats

The function returns value in different formats depending on the form control.

Form control

Format

Remarks

Form control

Format

Remarks

Bar/QR code scan

 

Returns numeric or alphanumeric value of the code

Bar/QR code show

 

Returns numeric or alphanumeric value of the code

Calendar

YYYY-MM-DD HH:MM

Returns the selected date

Checkbox

Set 0: 0 or 1
Set 1: OK
Set 2: OK or NOK
Set 3: OK or NOK or NA
Set 4: OK or NOK or NA

Returns the selected option (depending upon the set used)

Date

YYYY-MM-DD

Returns the selected date

Date Time

YYYY-MM-DD HH:MM

Returns the selected date and time (in 24-hour format)

File

<filename>.<extension>

Returns the name of the file

Form

 

Returns the unique identifier of the sub form

Identifier

 

Returns the identifier text

Image

 

Returns the binary data as callback parameter

Map

 

Returns the latitude and longitude of the selected co-ordinate in decimal degrees

Multiple choice

 

Returns the code of the selected dataset item

Numeric

 

Returns the numeric value

Numeric spinner

 

Returns the numeric value

Radio

 

Returns the code of the selected dataset item

Selectbox

 

Returns the code of the selected dataset item

Signature

 

Returns the binary data as callback parameter

Slider

 

Returns the numeric value

Text

 

Returns the text

Textarea

 

Returns the text

Time

HH:MM

Returns the selected time

Toggle

0 or 1

Returns the state of the toggle (off/on)