Scripts in channels and on buttons
Guide to OpenDIMS scripting
Syntax
Scripts have syntax very close to SQL, as we have used MySQL functions as inspiration.
All function calls must be in capital letters.
You refer to values with $ as in PHP.
Example:
CONCAT_WITH_SPACE(@USER.NAME,CONCAT(“<“,@USER. EMAIL,”>”))
Integrations
In an integration, you can use a script to set a specific value, just by typing the value.
You can also use these values:
$VALUESource field or item on the line
$NavnFraLinjenGet the value from a previous line by using the destination name (here the NameFromLine is used as an example of the recipient item name in a previous line)
Buttons
Just like in channels/integrations, you can also just write a fixed value in the script to set it.
On the script buttons, you can only retrieve these system values:
@USER.NAMEUser’s name
@USER. EMAILUser’s email
@USER. LAST_LOGIN_ATDate and time of the user’s last login
@USER. PHONEUser’s phone number
@USER. TITLEUser’s Title
@USER. CREATED_ATUser’s creation time
@USER. UPDATED_ATThe user’s last modified time
You can also use field values as you select on the field setup, you use these values by referencing them on the field name:
@StatusGet the value from the field named “Status”
! If field values are retrieved for the script, it is not calculated when creating data, but only when one of the field values that the script uses is saved/changed.
Fields
When a field name is used in a calculation, it must be the ENTIRE field name including spaces and with æøå, if it exists. If the field is called “My own item number”, the variable must be called “$Mit own item number”:
$Mit own item number
Examples of field names when used in calculations.
$MitPrim Field
$Hovedkategori
Example calculation
INTVAL($DandomainPrimary ID)
Features
IF(exp,arg1,arg2)
If exp is true arg1 is returned, arg2 is returned
OR(arg1,arg2,…)
Returns sand if arg1 is greater than arg2. Can handle all the arguments you give it.
AND(arg1,arg2,…)
Returns sand if arg1 is greater than arg2. Can handle all the arguments you give it.
GREATER(arg1,arg2)
Returns sand if arg1 is greater than arg2
GREATER_EQUAL(arg1,arg2)
Returns sand if arg1 is greater than or equal to arg2
LESS(arg1,arg2)
Returns true if arg1 is less than arg2
LESS_EQUAL(arg1,arg2)
Returns sand if arg1 is less than or equal to arg2
EMPTY(arg1)
Returns sand if arg1 is empty
INTVAL(arg1)
Returns the arg1 typecast to an integer
BOOLVAL(arg1)
Returns true if arg1 resembles a true value such as: 1, true, yes, active, open, true, yes, active, open
NOT(arg1)
Returns negating arg1
EQUAL(arg1,arg2)
Returns sand if arg1 equals arg2
CONTAINS(heystack,search)
Returns true if the text in search is in the heystack text
STARTS_WITH(heystack,search)
Returns true if the text in search is the start of the heystack text
ENDS_WITH(heystack,search)
Returns true if the text in search is the end of the heystack text
REPLACE(heystack,search,replace)
Returns true if the text in arg2 is the start of the arg1 text
NUMBER_FORMAT(number,[decimals=2],[decimal_sep= .],[thousand_sep=,])
Returns number formatted as English notation with 2 decimal places if nothing is specified in decimals, decimal_sep, and thousand_sep
DATE_FORMAT(date,format)
Returns data formatted as specified in format. See format values here:
PHP Date
MULTIPLY(arg1,arg2,..)
Returns the value of all arguments multiplied by each other
DIVIDE(arg1,arg2,..)
Returns the value of arguments divided by each other
ROUND(number,precision)
Returns number rounded with precision factor. Example ROUND(123.53,0.25) = 123.50 and ROUND(123.23242,0.01) = 123.23
ADDITION(arg1,arg2,..)
Returns the value of arguments added with each other
SUBTRACTION(arg1,arg2,..)
Returns the value of arguments subtracted from each other
SPLIT(separator,haystack)
Returns array value of haystack separated by separator
CONCAT(… args)
Returns all arguments concatenated without a separator.
CONCAT_WS(separator,… args)
Returns all arguments concatenated with the separator character (can’t use spaces).
!! Please note that you can NOT specify one or more spaces as a separator, instead use CONCAT_WITH_SPACE to link with spaces.
CONCAT_WITH_SPACE(… args)
Returns the value of all arguments concatenated by spaces.
SUBSTRING_INDEX(haystack,separator,index)
Returns string extraction specified by index of from haystack separated by separator. First string extraction is index 0.