1. Home
  2. Workflows
  3. Working With Variables

Working With Variables

When talking about variables in the context of Bosbec WE, we are usually referring to metadata. Metadata is where we store data to be able to process it later.

While metadata can be permanently stored on the account resources, it is often used as a temporary storage space when used in a Workflow Context.

Metadata

When you need to handle data in a Workflow, you’ll likely need to store it as metadata. In most cases, there will be a destination field where you can enter the metadata key to which you want to save the data, but in some cases, the jobs have predefined keys.

Accessing the data is usually done in a source field.

The standard syntax for accessing and storing metadata to and from the WFC is: 

metadata.[KEY]

For example, accessing or saving to the key “location” would be done by typing metadata.location.

Resources

Resources can be found on your account (permanent) or in a WFC (temporary). Many different types of resources are available, e.g., incoming API requests, units, or lists of data log items. These resources can have metadata that can be accessed and used in the WFC.

To access metadata on a resource in the WFC, use the syntax below.

[RESOURCE_NAME].metadata.[KEY]
[RESOURCE_NAME].[KEY]

The [RESOURCE_NAME].[KEY] version is usually used when accessing data from an incoming HTTP request or a JSON.

Finding the date and time that a resource was created is done using the following syntax.

[RESOURCE_NAME].createdon

This gives you the DateTime in “u” format, i.e., yyyy-MM-dd HH:mm:ssZ.

Incoming Message

The resource “Incoming Message” has a few specific keys that can be accessed using the format below.

incomingmessage.body - Access the message body
incomingmessage.htmlbody - Access the HTML body of an email
incomingmessage.sender - Access the sender (String-object)
incomingmessage.receivers - Get all receivers in a comma separated list (incl. CC and BCC for email)
incomingmessage.receiver - Get the main recipient.
incomingmessage.subject - Get the email subject.

Incoming HTTP request resource

The Incoming HTTP trigger automatically creates an HTTP resource. You can access the data from this resource by using the syntaxes below.

[RESOURCE_NAME].body

Fetches the request body.

[RESOURCE_NAME].headers
[RESOURCE_NAME].header.[HEADER_NAME]

You can get all headers as comma-separated text or only one by targeting specific header names.

[RESOURCE_NAME].path
[RESOURCE_NAME].fullpath / [RESOURCE_NAME].full_path

Get only the path from the request or the entire path.

[RESOURCE_NAME].url
[RESOURCE_NAME].querystring
[RESOURCE_NAME].querykeys
[RESOURCE_NAME].query.[KEY]

You can get the full query string (using URL or querystring), the different keys, or the value from specific keys.

[RESOURCE_NAME].content-type
[RESOURCE_NAME].contenttype

Content-Type can be accessed using the two formats above.

[RESOURCE_NAME].multitude

Fetches the resource’s Multitude property (which should almost always be Single for this resource).

[RESOURCE_NAME].requesterip
[RESOURCE_NAME].ip

Fetches the RequesterIpAddress.

IDs

Most resources in the Bosbec WE platform will have an identifier. This is commonly accessed using the syntax below.

[RESOURCE_NAME].id

In addition, a resource will usually have the ID of the administrator and account that created it. This can be accessed using this format:

[RESOURCE_NAME].administratorid
[RESOURCE_NAME].accountid

Share lists

Information about a resource’s share lists can be accessed with the following features.

[RESOURCE_NAME].sharing.owner
[RESOURCE_NAME].sharing.sharelists
[RESOURCE_NAME].sharing.access

These features will give you the owner of the resource, share lists they are included in, and if they are public or private.

Units

Unit resources have specific data that can be accessed in the engine such as phone or email. The following commands are specific for unit resources. Note that where we are writing “unit,” you can use any unit resource name instead.

unit.phone / unit.phonenumber

unit.phone.country
unit.phone.countryiso

Both “phone” and “phonenumber” will give you the unit’s phone number. “Country” will look at the phone numbers country code and give you the country name, while “countryiso” will give the two-letter country code, i.e., Sweden or SE.

Accessing the email address can be done with the following syntax.

unit.email
unit.emailaddress

App users are accessed in a similar manner:

unit.appuser
unit.appuserid

You can also check if the user has an active push channel with the following function. This will give you a true or false value.

unit.hasfeedchannelwithpush()

If you want to know how many channels a unit has, you can count them using the following function.

unit.channels.count()

Tags can be accessed and listed by using this function.

unit.tags.tojson()

Variable functions

The Bosbec Workflow Builder includes built-in functions to alter and create data. For example, use these functions to create and format dates or generate random characters and values.

DateTime

Current date and time.

Set the format inside the parenthesis, or leave them blank for standard format (yyyy-MM-dd HH:mm:ssZ).

[datetime()]
[datetime(yyyy-MM-dd)]
[datetime(yyyy-MM-dd HH:mm:ssZ)]

Subtract time from the current date and time:

[datetime().subtimespan(ddd.HH:mm:ss)]

Add time to the current date and time:

[datetime().addtimespan(ddd.HH:mm:ss)]

Generate random

Generate a random number from 0 up to a certain number:

[rndnum(50)]

Generate a random number within a certain range:

[rndnum(10,100)]

Generate decimal value ranging from 0 to 1:

[rnddecimal()]

Generate X amount of random letters:

[rndalpha(5)]

Generate X amount of random characters:

[rndchar(X)]

Generate a Globally Unique Identifier:

[uid()]

Case

Set upper case. Add the function to the destination field.

metadata.[KEY].toupper()

Set lower case. Add the function to the destination field.

metadata.[KEY].tolower()

JSON

Get metadata and save it as JSON.

metadata.[KEY].tojson()

Count

Count number of items in a resource. For example, count all units in a unit resource.

In the source field, add .count() to the end of the resource.

[RESOURCE_NAME].count()

Alt1 Syntax

The new syntax uses {{ }} to indicate that we are replacing the text with a dynamic value. More on this can be found on Workflow Builder Expression Syntax.

Default Value

To replace a value with a default value in case there is no data on the specified key, you can use the defaultvalue() function.

{{defaultvalue( "{{metadata.key}}" || "No value" )}}

This example would save the string “No value” to the destination if metadata.key cannot be found or if it’s empty.

Updated on 2024-11-18

Was this article helpful?

Related Articles

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
Contact Support