It is all about managing and manipulating data. Data are kept in relational tables and their columns are always of given type. Hence scripting is also strictly type defined. Whatever you do with any value it is connected to its type.
It is supposed you are familiar with basic types of your data columns and that is sufficient.
Each record of your data is treated as an object, each column value is also an object (maybe smaller, yes)
By saying object I mean you can always write a dot
afterwards and see your further methods or properties.
E.g. CurrentUser().FirstName will return the first name of the currently logged user
E.g. CurrentUser().FirstName.StartsWith("a") will return if the first name starts with letter a
You may have columns in your tables being formulas
In order to define a formula you need to write 'one line statement' calculating your output. Always starting with =
E.g. suppose we have two fields, both of type User, one is to be entered, and second calculated = User1.Manager
Summaries and summaries for search
Summaries are the default formulas representing a record of data. Usefull with searching and lookoups
Imagine you have two tables Pupils and Schools and they are connected with lookups so each Pupil attends particular School
When viewing or editing a pupil you need show that School, but how to show a school? Record School may consist of 10 attributes like Name, Director, City, Achievements, Description.
Summaries come here with help. First, we need a small formula, probably string concatenation so each School will be visible as Name (City)
Formula of Summary of School can look like = Name + "(" + City + "")"
that is enough when presenting a pupil, its lookup to School will then look nice: HighSchool 23 (Warsaw)
Search Summary is a bit more complex as we need a bit more information when searching e.g. when choosing a school we need to look for with post code yet
that case when editing a pupil we have more information, but once chosen presentation form is shorter
Conditions are specific formulas, since they always return Yes/No (Bool)
They are usefull with rules, dynamic showing or hiding actions, fields etc.
Filters (views, webparts, lookup filters)
Filters used to narrow table records are a bit different thing since we want them to operate directly on the level of database, not in the application layer
There are two main differences:1) you can write a filter (or if you prefer a where statement) using a column first, then operator, then static value. You may not change that order e.g. Column > 5 and not 5 < Column2) strings presented with apostrophes 'text' and not quotations as with other scripting "text"
Operators and brackets
Feel free to use any operators e.g. +, -, *, /, AND, OR, >=, and nest brackets as you like e.g. a > 3 AND (b = 5 OR b = 3)
Bear in mind there is a function NOT(bool expression) the will evaluate to opposite bool value, it is not an operator
All of the above are one line statements, but when some record is added or action is taken we may need to do more.
There are events like OnActionBefore, OnUpdateAfter, OnDeleteBefore we may write scripts
Basically you just write statements one after another, no new lines (enters) are neccessary but very helpfull with readibility.
# means your own comment till the end of line e.g. i = i + 1 # just adding one
Assignment is made just with = whenever on the left side is a column or variable
All names are case insensitive. When copying take care about quotations marks as they like to differ
Scripting Variables (Var)
You can use variables as you like declaring them with VAR. When declaring you don't provide a type. When variable is assigned a value type is then assigned as well
var a = 1, b = "bbb", c = GetCurrentUser()
Scripting Conditionals (If)
There are two types of conditionals
1) If(), If2(), If3() one line functions usefull in formulas and conditions
2) IF condition THEN blockOfCodeWhenYes ELSE blockOfCodeWhenNo ENDIF statement
Scripting Loops (ForEach)
You may repeat given block of commands by enclosing them in FOREACH variableName IN multiObject
e.g. Var USER, NAMES
ForEach USER in MyColumn.Users Names = Names + USER.LastName + "," EndForEach
e.g. Var PUPIL, NAMES
ForEach PUPIL in GetTable("Pupils").GetRows("FirstName>'k'") Names = Names + PUPIL.LastName + "," EndForEach
Scripting adding new records, new processes, updates
Data are kept in tables, but each data record can be associated with many processes and subprocesses. You need to understand the difference so data can be inserted, updated and deleted, but processes can be only started or action can be taken. By deleting a data record you also delete all associated processes and subprocesses.
Example for inserting new data: var n = New("tableName") n.Title="some title" n.Insert("some comment or empty string")
Example for updating a data record: var n = GetTable("tableName").GetFirst("Id=5") n.Title="title change" n.Update("some comment or empty string")
Example for starting a new process (with data record in the background): var n = NewProcess("Workflow Title") n.Title="some title" n.Start("some comment or empty string")
Scripting events (running on special occasions)
There are events fired on special occasions like adding a new record, starting process, leaving a state etc. There are few aspects to bear in mind.
Some of them are available in two variants BEFORE or AFTER operation. The BEFORE does not create additional entries in log and does not need final Update() (more convenient whenever possible) e.g. if you write A=5 in the event of OnInsertBefore the real operation Insert will assign A=5 with one sql insert (no need for additional updates, no need for additional log). Sometimes you will need AFTER events e.g. ID of the record will be known in OnInsertAfter.
Sql transaction always covers all the operation with events in one. Whenever problem/exception arises in the event before or after the whole process is rolled back!
OldValue() function helps in accessing the oryginal value e.g. you want to compare old values with new entered by the user e.g. If Name = OldValue(Name) THEN ... EndIf
Stop("I don't want X. Write something else") function helps in stopping operation e.g. If Name="X" THEN Stop("...") EndIf
Custom services (background tasks)
If you need to run some tasks regularly e.g. every 5 minutes or every month you may easily use the scripting techniques in custom service added on the level of area
Global functions available for scripts e.g. CurrentUser()
Object methods e.g. MyStringField.Substring(...)