sfGetValue
Returns the value of a form control.
Syntax
sfGetValue(id, index, propertyName, callback)
Parameters
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:
Applicable only to Image and Signature controls. See callback function. |
Applies to
Control type | Applicable | Remarks/Exceptions |
---|---|---|
Yes |
| |
No |
| |
No |
| |
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 |
---|---|---|
| Returns numeric or alphanumeric value of the code | |
| Returns numeric or alphanumeric value of the code | |
YYYY-MM-DD HH:MM | Returns the selected date | |
Set 0: 0 or 1 | Returns the selected option (depending upon the set used) | |
YYYY-MM-DD | Returns the selected date | |
YYYY-MM-DD HH:MM | Returns the selected date and time (in 24-hour format) | |
<filename>.<extension> | Returns the name of the file | |
| Returns the unique identifier of the sub form | |
| Returns the identifier text | |
| Returns the binary data as callback parameter | |
| Returns the latitude and longitude of the selected co-ordinate in decimal degrees | |
| Returns the code of the selected dataset item | |
| Returns the numeric value | |
| Returns the numeric value | |
| Returns the code of the selected dataset item | |
| Returns the code of the selected dataset item | |
| Returns the binary data as callback parameter | |
| Returns the numeric value | |
| Returns the text | |
| Returns the text | |
HH:MM | Returns the selected time | |
0 or 1 | Returns the state of the toggle (off/on) |