Set Variable Value
- 1 Set Variable Value
- 2 The Different Types of Value
- 3 Variable Operations
- 3.1 Clear Custom Field / Clear JSON
- 3.2 input value
- 3.3 Math Formula
- 3.4 Set Text Variable
- 3.4.1 trim text
- 3.4.2 sub string
- 3.4.3 replace string / replace string case sensitive
- 3.4.4 to lower / upper case
- 3.4.5 generate random text
- 3.4.6 url encode / decode
- 3.4.7 base64 encode / decode
- 3.4.8 to URL friendly slug
- 3.4.9 get text before/after
- 3.5 Set Number Variable
- 3.6 Set DateTime Variable
Set Variable Value
This action allows you to store a value inside a variable or a custom field. This is very useful when you want to collect data from your users.
The Different Types of Value
Once you click on the set custom field action, you’ll be able to choose which custom field needs some to update in terms of value.
You can either put in some data or even another custom field as a value as well.
Should you need to create a new custom field, just type in the name and choose the type of custom field you’d like to create.
Variable Operations
UChat provides you with various built-in operations for variable modification.
There are 6 types of variable in UChat:
Type | Storage | Example | Operation |
---|---|---|---|
Text | letters, words, sentences... | Hi, UChat. | cutting, change case, encode, decode... |
Number | number | 123.45 | + - x ÷, mod, power, log, root, round... |
Boolean | either "yes" or "no" | yes | assign |
Date | date | 2021-03-30 | format, add months/weeks/days |
DateTime | date and time | 2021-03-30 16:52:00 | format, add months/weeks/days/hours/minutes |
JSON | a series of variables | {"name":"jack", "age":"10"} | load, get, update, remove, count, sum, average, sort, shuffle, reverse... |
Â
Â
Click "Basic Actions" in the Action step and here are the "Set Variable Value" and "Clear Variable Value".
Â
Clear Custom Field / Clear JSON
To clear text, number, boolean, date, datetime variable, please use the Clear Custom Field action.
To clear JSON variable, please use the Remove All Items operation in the JSON Operation.
Â
input value
"input value" operation is used to assign value to a variable. This operation works for any variable type.
Â
TIP - "input value" for text variable can be used to connect several text variables. See the below picture for where to put original value and operated value.
Â
Â
Math Formula
Â
With this operation, you can now do formula calculation directly in the Action Step - "Set Variable Value" and Condition Step - "Value".
Math operations and function supported:
+, -, *, e, pi, PI, abs(), min(), max(), ceil(), floor(), log(), pow(), round(), sqrt(), sin(), cos(), tan()
Â
Please note that If the formula is invalid, the system will return 0 to number variable and empty to text variable.
Â
Set Text Variable
trim text
Description | e.g. Before | e.g. After |
---|---|---|
remove spaces before or after the text | " abc" | "abc" |
Â
Â
sub string
Description | e.g. Before | e.g. After |
---|---|---|
get part of the text | "Hi, UChat!" | "UChat" |
Â
Â
Note - Index starts from 0. Every character counts including space and punctuation.
Â
Â
replace string / replace string case sensitive
Description | e.g. Before | e.g. After |
---|---|---|
replace part of the text | "Hi, UChat!" | "Hello, UChat!" |
Â
Â
Â
Â
to lower / upper case
Type | e.g. Before | e.g. After |
---|---|---|
to lower case | "Hi, UChat!" | "hi, uchat!" |
to upper case | "Hi, UChat!" | "HI, UCHAT!" |
Â
Â
generate random text
Description | e.g. Before | e.g. After |
---|---|---|
as the name | "code: XXXX-####-xxxx" | "code: UBWT-3657-lkzb" |
Â
Â
This feature is useful when you need to generate one-time verification code or reference code.
Â
url encode / decode
Type | e.g. Before | e.g. After |
---|---|---|
encode | "Hi, UChat!" | "Hi%2C%20UChat!" |
decode | "Hi%2C%20UChat!" | "Hi, UChat!" |
Â
Â
base64 encode / decode
Description | e.g. Before | e.g. After |
---|---|---|
encode | "Hi, UChat!" | "SGksIFVDaGF0IQ==" |
decode | "SGksIFVDaGF0IQ==" | "Hi, UChat!" |
Â
Â
to URL friendly slug
Description | e.g. Before | e.g. After |
---|---|---|
replace spaces with hyphens and remove the rest signs | "it's a good day" | "its-a-good-day" |
Â
Â
get text before/after
Description: get part of the text.
Type | e.g. Before | e.g. After |
---|---|---|
get text before another text | name: UChat, city: Melbourne | name |
get text before last occur of another text | name: UChat, city: Melbourne | name: UChat, city |
get text after another text | name: UChat, city: Melbourne | UChat, city: Melbourne |
get text after last occur of another text | name: UChat, city: Melbourne | Melbourne |
Â
Â
Set Number Variable
get text length
Description | e.g. Before | e.g. After |
---|---|---|
as the name | 500.59 | 6 |
Â
Â
generate random number
Description | e.g. Before | e.g. After |
---|---|---|
as the name | n/a | 56 |
Â
Â
add / subtract / multiply / divide / modulus / power / natural logarithm / square root
Description | e.g. Before | e.g. After |
---|---|---|
as the name | 7 | 8 |
Â
Â
Â
round
Description | e.g. Before | e.g. After |
---|---|---|
as the name | 7.8693 | 7.87 |
Â
Â
floor / ceil
Description: get approximate integer.
Type | e.g. Before | e.g. After |
---|---|---|
floor | 6.55 | 6 |
ceil | 6.55 | 7 |
Â
Â
Set DateTime Variable
from formatted text
Description | e.g. Before | e.g. After |
---|---|---|
get DataTime value from formatted text | 00:00:00 30th Aug, 2020 | 2020-08-30 00:00:00 |
Â
Â
add minutes / hours / days / weeks / months
Description | e.g. Before | e.g. After |
---|---|---|
as the name | 2021-01-01 00:00:00 | 2021-01-01 00:01:00 |
Â
Â