Variables in Aliveforms
Variables are very useful and important element in Aliveforms. Basically, a variable is something that holds a value.
Uses of variables in Aliveforms
In Aliveforms, variables are used for many purposes, such as
- In screen title, Showing input of one screen in other such as name.
- In screen title, for calculation, such as price calculation, performing math.
- In hidden inputs, such as calculating time taken by user to complete the form. any many more.
Read about Calculations in Aliveforms
What are variables?
Variables are basically dynamic values. In Aliveforms, there are multiple types of variables in Aliveforms.
- System Variables
- User Defined Variables
Info
Do not confuse Aliveforms Variables with JavaScript variables.
Using variables in form
In Aliveforms, variable can be uses with double square brackets syntax [[VARIABLE]]
. - System defined variables can be can accessed and used with [[SCREEN.INDEX]]
e.g. [[SCREEN.0]]
. Screens like Contact, Address, Dynamic List, Matrix, Compound Input, Multiple Choice with multiple select allowed, are lists. If you need to access individual element, provide extra sub-index like [[SCREEN.INDEX.SUBINDEX]]
e.g. [[SCREEN.0.0]]
. If sub-index is not provided, then all members of list are concatenated. - Response variables are similar to user defined variables like [[VAR.RES:ID]]
. - User defined variables like [[VAR.VARIABLE_NAME]]
. - You can access list index like [[VAR.LIST.INDEX]]
.
System Defined Variables
A system defined variable can have input of screen, score of screen, server response variables have response from server stored in special variables etc. In Aliveforms, there are 4 system defined variables. - Screen - Score - Params - Response
User Defined Variables
A user defined variable is defined by user using actions in logic or script. It can store a number, string or list etc. A variable can also reference other variables.
How to define use variable in Aliveforms.
A user variable can be defined using actions or JavaScript API.
Using actions
Add Action Define variable, then enter name and value If it is string, quote it like "X" if it number type it like 10 or 15 if it is list, ["10", 1,12]
Using JavaScript API.
Use $.Var to define variable.
How to store variable in other variable
You can reference other variables like [[REF.VARIABLE]]
or you can use [[VAR.VARIABLE]]
What is difference between VAR and REF
REF is handled again after VAR
How to Evaluate Math?
Write Math Between [/ /]
. Like [/ 10 * 10 /]
[/ [[VAR.MULFACTOR]] * [[SCORE.1]] /]
[/ [[VAR.MULFACTOR]] - 10 /]
System Defined Variables
Variable | Use | Example |
---|---|---|
SCORE | Total weight (Analytical Form Only) | Total Bill is [[SCORE]] |
SCORE.INDEX | Weight of screen (Analytical Form Only) | [[SCORE.1]] |
SCREEN.INDEX | Input of Screen | You selected [[SCREEN.2]]! |
SCREEN.INDEX.JOIN | Option texts of List or Options Screen, Joined with JOIN Character | Hi [[SCREEN.1.,]]! |
SCREEN.INDEX.SUBINDEX | Sub Index is field in case of compound input | Hi [[SCREEN.1.0]]! |
PARAMS.KEY | Query Parameter | [[PARAMS.src]] |
Important
If screen is Multiple Options or Dropdown then it will display the options text.s
Screen Type and SCREEN.INDEX
If screen type is compound screen, i.e. Address, Contact, Compound Input or Dynamic List or Matrix, it uses SCREEN.INDEX.SUBINDEX
syntax
Response Variables
Variable | Use | Example |
---|---|---|
RES:RAWMESSAGE | Raw/Original message returned by message. | |
RES:MESSAGE | Message returned by server | |
RES:GROUPS | Array of Groups names and values built after server logic units. | |
RES:MAXGROUP | Name to dominant group from server logics. | [[VAR.RES:MAXGROUP]] |
RES:SCORE | Total Score of quiz or total weight of weight based form. | Your score is [[VAR.RES:SCORE]] |
RES:ID | Id of submission. Can be used for order tracking etc. | Your order id is [[VAR.RES:ID]] |
RES:INTEGRATION | Output of integration. Requires the name to be provided. It is better to use with JavaScript Logic Unit | Read Below |