Guide - Data types in Streamscript
Streamscript supports all data types on all objects, including standard, custom, managed, platform events, custom metadata, where the running user has CRUD and FLS permissions.
| Text |
'Hi' |
|---|---|
| Number |
12.3 |
| Boolean |
true |
| List |
[ 'GenWatt', 'Burlington' ] |
| Map |
{ age: 24, medical: true }
|
| Date |
'2023-01-31' |
| Date/Time |
'2023-01-31T23:59:59.000Z' |
| ID |
'0010Q00001dMfMQQA0' |
| Binary Blob |
'JVBERi0xLjM=' # base64 |
| SObject |
{
Name: 'GenWatt'
IsDeleted: false
NumberOfEmployees: 150
attributes: {type: 'Account'}
}
|
Variables
You can assign any data type to a variable:
$num = 123.4
Flow resources are already available within a script:
$Contact = {!$Record}
$greeting = `Hello $Contact.Name`
$message = `$greeting \n Form submitted at {!$Flow.InterviewStartTime}`
Collection Types
There is no need to declare variable types. All collection variables support mixed types within the collection, like this:
$items = [ 123.4 'hello world' ]
Type Conversion
Sometimes integrations return data in an unexpected type. In these cases you can convert its type. For example:
Map to Text
$map = {first: 'Peter', last: 'Hopkins', medical: true, age: 24}
$url = $map.toUrl() # 'first=Peter&last=Hopkins&medical=true&age=24'
Text to Number
$text = '124.3' $number = $text.toNumber() # 124.3
Value to Boolean
$num = 1 $text = 'false' $bool1 = $num.toBoolean() # true $bool2 = $text.toBoolean() # false
Text to Maps
$json = '[{"name":"peter","age":23},{"name":"jane","age":19}]'
$maps = Json-Decode $json
$ageOfJane = $maps.1.age # 19
List to Text
$list = [192, 168, 1, 10]
$ipAddress = $list.join('.') # 192.168.1.10
For a complete list of type conversion methods, see the reference: Type convert methods
JSON Types
Any valid JSON value is also a valid Streamscript value. For example:
# JSON - valid Streamscript
$map = {
"age": 24,
"medical": true,
"name": "Hopkins"
}
Commas are optional. For example:
# Also - valid Streamscript
$map = {
age: 24
medical: true
name: 'Hopkins'
}