<< Click to Display Table of Contents >>
Scripts |
Scripts in Elipse Mobile are written in JavaScript. The available global parameters for access via scripts in a Form are described on the next table.
Parameters of a script on a Form
Parameter |
Description |
---|---|
state |
Status of a Form. Possible values for this parameter are 0: Pending, 1: Attributed, 2: Finished, or 3: Approved |
assignedUser |
Name of a user attributed to a Form |
user |
Name of the user responsible for the last change on a Form |
timestamp |
Date and time of the last update on a Form |
fields |
Fields of a Form |
To access the parameters described previously, use the format described next.
WriteTag("demo:TagInternal1",
form.assignedUser,
function(er) {
});
Fields on a Form, in the fields parameter, contain an id property, which is the internal code of a Field, the notes property, in the case of Fields with additional notes, the value property, which is the value of a Field, and the timestamp property, which is the date and time of the last update of a Field. Access to properties of a Field must be performed according to the next example.
WriteTag("demo:TagInternal1",
form.fields.field1.value,
function(er) {
});
When an answer is created on a Form, an OnChange event is triggered in the server. This event can be used to validate a Form, to copy data to another system, or to send an e-mail notifying changes to a Form, according to the next example.
function OnChange(form) {
//If the state parameter is equal to 2,
//Field's value is written to TagInternal1
if (form.state == 2) {
WriteTag("demo:TagInternal1",
form.fields.field1.value,
function(er) {}
);
}
}
To create a script for scheduling the creation of a Form on a specific day, for example, follow the next procedures in a Demo-type Connection.
1.Select the Events tab and click Add .
2.Select the Script item.
3.Type a name for this event.
4.In the Condition option, type the next expression.
(new Date(ValueOf("demo:_now"))).getDay() == 5
5.The previous expression creates a new JavaScript Date object from the _now Tag and compares it to the value 5 (five, Friday).
NOTE |
For more information about the Date object in JavaScript, please check its documentation on Mozilla Developer Network (MDN). |
6.In the Script option, type the next source code.
SendMail("user",
"Form filling",
"Message",
function(er) {
});
7.This script is executed when the event enters a true condition, that is, when the weekday is equal to Friday. On all other days this script is not triggered.