Ds
Last updated
Was this helpful?
Last updated
Was this helpful?
The ds
expression function is useful for when you want to use the value of a databox multiple times in one expression.
ds
Number*Number(ds)
3
9
‘ds’ represents the original DataBox Value. In this example 3x3 = 9
A simple example of this would be to use it to square a number, multiply it by itself.
The user enters a number which is written into the databox Examples.ds.
Examples.ds.Square value converts the value into a Number and then multiplies it by the original value Number(ds).
Number * Number(ds)
For example if you enter 9
Number(9) * Number(9) = 81
The result is written into Script.Details and output to a message as shown below...
A more complicated use would be to have an SQL query retrieve a value from a number of possible values from a database, then convert the retrieved value into something else.
This example uses a dynamic question to get a value from a database and write it to a databox, the expression in this databox then checks the value and outputs text to a message depending on the value. This has been used by a client to look up a numeric code from their Housing Database and convert this code into different phone numbers to call depending on the property location.
So if the User selects RD then a value of 1 is returned and this is converted into "Diagnostics Scripts" FL returns 2 and converts into "Enquiry Scripts" ROL returns 3 and converts into "Repairs Online" EOL returns 4 and converts into "Enquiries Online" BEN returns 101 and converts into "Benefits" OC returns 102 and converts into "Office Care" Test returns 900 and converts into "Test Scripts"
The expression to do this is as follows:
This expression first looks to see if the value in the databox is '1', if it is then 'True' will be returned, in this case 'True' will be replaced with 'Diagnostics Scripts'. If it is not '1' it'll return a value of 'False', in this case 'False' will then be replaced with the original value (ds) and the expression will check to see if that is '2', if so it'll return a value of 'True', the 'True will be replaced by 'Enquiry Scripts... and so on until either something has come up as 'True' or all the checks have resulted in 'False'. This is shown below...