The skybow Expression Builder helps you to intuitively add calculations, default values, hide/when conditions, validation rules and more without extensive programming language. That's a perfect tool for citizen developers.
Below, we will explain how to calculate field values with the expression builder.
You can access the Expression Builder whenever you see the "{}"-icon for the element that you want to set the expression for.
Once you have opened the Expression Builder, you will see three tabs: Template, Assignment, and Function.
Template
Used for building concatenations without the complexity of using operators, e.g. Full name is [[FirstName]] [[LastName]] would evaluate to full name is Sarah Amler.
Assignment
Used for building calculations or expressions with operators that return a value, e.g. [[SalesTax]]+[[SubTotal]]
Function
Used for building expressions using JavaScript, e.g. var date = new Date();return date;
Placeholders
Placeholders can be double-clicked or dragged into the expression window. The placeholders include:
- Fields within your form
- Contextual Values
- Sublists
Fields
Fields can be double-clicked in order to use the field as part of your expression. The fields can also be expanded to show "OriginalValue", "IsChanged", or "IsInvalid". The latter two are helpful when building validation rules against fields.
The outcome of your expression can be tested against a list item using the "Test" button at the bottom of the expression pane.
Context
The context placeholders enable you to retrieve properties from the context of your form. Your form is within a list, which is in a site, which is in a site collection. It's being accessed by the current user on the current page. Properties can be retrieved from each of these contextual properties:
Form:
Properties about the form you are on, such as "ItemID" and "ListID". "IsDisplayForm", "IsEditForm", "IsNewForm", and "IsSubListForm" are helpful when applying conditions like formatting or validation.
Page
The current page properties such as "CultureName", "GetQueryString", "UICultureName" and URL.
Site
The Site Collection that you are in. "GetFirstValueForQuery" and "GetValuesForQuery" enable you to retrieve values using CAML Queries. "ServerRelativeURL" and URL can bring back the URL of the current site collection.
User
Return information about the current user such as Title, Login Name, Location, and Email. Two functions can be used to test if a user is a member of a SharePoint group or Azure Active Directory Group. These include "IsMemberofGroup" and "IsMeberofAADGroup".
Web
Returns information about the current site, e.g. Title, URL, Language and "GetValues" queries.
Sublists
Using the Expression Builder, you can access sublists to get at the columns within the sublist, and use a summary function against the related items, e.g. Sum, Min, Max, Count.
Field Controls
Fields in skybow contain controls for configuring complex business logic. Flexibly configurable, expression-based behaviour provide an easy way to make a field or form section dynamically, show or hide, or become enabled or disabled depending on other inputs. Values can also be set and recalculated while the user is entering data in the form.
Visible
Allow to change the visibility of any selectable element at run-time based on conditions.
For example, you can hide or show form controls based on conditions. As an example, a field can be shown only when the field "Status" is set to "Active": =[[Status]]== ‘Active’
Enabled
Enabled expression enables or disables any selectable element at run-time based on conditions.
For example, you can disable elements that are not allowed to be edited depending on other field values or disable a button to prevent the user from clicking it depending on his group memberships.
Initial
Initial value expression allows to assign a default value to a field. This can be a constant or a calculated expression.
For example, you can set current date as a default value: ‘= new Date()’. Other date expressions include:
= new Date(2024, 5, 3) | Set the date to 3rd June 2024. Note: The month (2nd) parameter is 0-based, so January is 0 and December is 11. |
= new Date().addDays(10) | Set the date to current date (and time) plus 10 days. Use addDays(-n) to subtract n days. |
= new Date().addHours(4) | Set the date to 4 hours in future. |
= new Date().addYears(-1) | Set the date a year ago from today. |
Calculated
Calculated expression provides a flexible way to dynamically recalculate the value while the user is entering data in the form. Whenever the value of a form field referenced in the calculated expression is changed, the expression is recalculated and the dependent field’s value set with the result.
For example, you can use it to perform a mathematical calculation. Multiply the values contained in two fields in order to produce a Total Amount in the current field: ‘=[[Price]]*[[Count]]’
You can also calculate date time fields.
=[[SomeOtherDate]] | Get the date time field of another date time field. |
=[[SomeOtherDate]].addDays(10) | Get the date time field of the SomeOtherDate column plus 10 days. |
{ if ([[ContractType]]==“Monthly”) return [[StartDate]].addMonths(1); else if ([[ContractType]]==“Quarterly”) return [[StartDate]].addMonths(3); else if ([[ContractType]]==“Semi-Annually”) return [[StartDate]].addMonths(6); else if ([[ContractType]]==“Annually”) return [[StartDate]].addYears(1); else return null; } |
Get a date depending on the value of field ContractType and StartDate. When ContractType is “Monthly” the date is calculated as StartDate plus 1 month, when ContractType is “Quarterly” the date is calculated as StartDate plus 3 months, etc. If ContractType does not match any of the checked values no date is returned. As an example this function expression could be used as a calculated expression to set the RenewalDate field of a contract item. |
Validation and Validation Text
Validation expressions provide an easy way to specify required form input.