Data Types

These Salesforce data types are supported in Streamscript:

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

Data from any of the types may be assigned to a variable like this:

$num = 123.4

Flow resources are already available within a script - for example:

$Contact = {!$Record}
$greeting = `Hello $Contact.Name`
$message = `$greeting \n Form submitted at {!$Flow.InterviewStartTime}`

 

Collection Types

There is no requirement to define the type of data assigned to a variable. All collection variables support mixed types within the collection, like this:

$items = [
  123.4
  'hello world'
]

 

Type Conversion

You may have integrations that receive data in a different type than intended. In these cases you can convert its type. Here are some typical examples:

 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

All type convert methods are listed in 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'
}

 

Getting started with Streamscript
Install from the Salesforce AppExchange
Direct install URL: /packaging/installPackage.apexp?p0=04t7F000005N1wy