Functions
When adding or editing an action's activity, you can use lookups. Lookups grouped under functions are particularly useful.
Lookups involving functions are divided into subgroups: Text, Date, Math, Data Sources, JSON, XML, Logical, Array, and Utilities.
Text functions
Text functions offer ten available options, including functions such as Find in Text, Length, Right, and To Text. The screenshot below shows all text functions available in Workbox.
Here, we will show only the view of fields to be filled in the designer for a few selected functions from the Text group.
Find in Text function
This function finds a text string (Text To Find) within another text string (Within Text). Then it returns a number of the starting position of Text To Find string in relation to the first character of Within Text string.
Replace Text function
This function replaces all occurrences of the specified string with another string.
Left function
This function returns the first character or characters in a text string, based on the number of characters you specify.
Substring Before function
This function returns a fragment of provided text from its beginning to the first occurence of a given string.
To Text function
This function converts the value of the specified object to its equivalent string representation using the specified culture-specific formatting information.
Date functions
Date functions are: Now, Modify Date, Date Difference, Datepart, Create Date, Format, Parse.
Let's analyze a few selected Date functions.
Now function
Starting with the Now function. This function returns the current date and time.
Example In the Edit item activity, we set a lookup to the Now function as the value.
When the action containing this activity is executed, the current date will be returned in the appropriate column on the list.
Modify Date function
The next function we will introduce is the Modify Date function. The function modifies the specified date by adding or subtracting years, months, days, hours and minutes you specify.
Example In the Add item activity, we set a lookup to the Modify Date function as the value.
The date to be modified is 2005/05/20. The screenshot below shows the specified date and the values by which it should be modified.
When the action containing this activity is executed, the appropriately modified date will be returned in the column on the list.
Date Difference function
The next date function to be discussed is Date Difference. This function calculates the number of years, months, days, hours, minutes or seconds between two dates. The difference is calculated by subtracting the start date from the end date. For the difference in months and years smaller time units are ignored in the outcome, for example: for dates 01/30/2009 and 02/01/2009 the result for months is ‘1’, while for dates 01/01/2009 and 01/30/2009 the outcome difference for months is ‘0’.
Exemple In the Edit item activity, we set a lookup to the Date Difference function as the value.
2007/12/24 is selected as the start date and as the end date 2010/08/25. The type of value to be returned is set to years. The function is to return the difference of years between the above dates.
When the action containing this action is executed, the difference in years will be displayed in the number column of the list.
Datepart function
Datepart function returns a number representing the specified part of the entered date such as the number of year, months days, hours, minutes or seconds.
Example In the Edit item activity, we set a lookup to the Datepart function as the value.
2024/10/02 is entered as the selected date, and the activity is to return the number of months.
When the action containing this activity is executed, the number of months of the entered date will be displayed in the number column in the list.
Math function
There is one Math function implemented in the workbox called Calculate. This function calculates the given mathematical expression.
Calculate function
Example In the Edit item activity, we set a lookup to the Calculate function as the value.
We will enter the mathematical expression 150+30.
When the action containing this activity is executed, the result will be displayed in a column in the list.
Data Sources functions
There are two Data Sources functions: Call REST Service and Query SQL.
Call REST Services function
The function sends and receives data to/from the REST web service. If no value is specified in the non-required fields, default values are used.
Query SQL function
This function you can use to communicate with SQL database.
JSON function
Three JSON functions are available: Select, Replace Tokens and Parse.
Here, we will show only the view of fields to be filled in the designer for a selected function from the JSON group.
Select function
This function selects a collection of elements using a JSONPath expression.
XML function
Three XML functions are available: Select Nodes, Replace Nodes and Parse.
Here, we will show only the view of fields to be filled in the designer for a selected function from the XML group.
Replace Nodes function
This function replaces XML nodes selected with given XPath expression.
Logical function
There is one Logical function implemented in the Workbox called If.
If function
In the If function, we set a condition that the title column field must not be equal to the word car. When the value in the title column field meets this condition, the text column will return Yes. However, if the value in the title column field does not meet the condition, meaning the word car is present, the text column will return No.
Array function
Nine Array functions are avaiable: Join, Concatenate, Take, Take Last, Count, Max, Min, Get Element and Split.
Here, we will show only the view of fields to be filled in the designer for a few selected functions from the Array group.
Join function
First, the Join function. This function joins the elements of a specified array, using the specified separator between each element.
Concatenate function
This function concatenates two arrays into new one that contains the elements of both.
Min function
This function returns the minimum value in an array of numbers. Skips non numeric elements.
Utilities function
There is one Utilities function implemented in the Workbox called New Guid.
New Guid function
This function generates and returns a new guid.
When the action containing this activity is executed, the new guid will be displayed in a column in the list.