apps
2024.10
true
- Getting Started
- Before You Begin
- How To
- Notifications
- Using VB Expressions
- Designing your App
- Events and Rules
- Rule: If-Then-Else
- Rule: Open a Page
- Rule: Open URL
- Rule: Close Pop-Over/Bottom Sheet
- Rule: Show Message
- Rule: Show/Hide Spinner
- Rule: Set Value
- Rule: Start Process
- Rule: Reset Values
- Rule: Upload File to Storage Bucket
- Rule: Download File From Storage Bucket
- Rule: Create Entity Record
- Rule: Update Entity Record
- Rule: Delete Entity Record
- Rule: Add to Queue
- Rule: Trigger workflow
- Leveraging RPA in your App
- Leveraging Entities in Your App
- Leveraging Queues in Your App
- Leveraging Media in your app
- Leveraging Actions in your app
- Application Lifecycle Management (ALM)
- Basic Troubleshooting Guide
Useful VB functions
Apps User Guide
Last updated Nov 11, 2024
Useful VB functions
This page contains VB expressions that you may find useful while building your app.
We grouped several of these functions in a public app, so you can try out them out and see how they behave.
The
Where()
function returns a zero-based array containing a subset of a string array based on a specified filter criteria.
Assume you have a variable called
words
defined as List(Of String) = {"apple", "banana", "cherry", "date"}
.
To get the list of words that contain the letter "a", apply the
Where()
function as follows:
words.Where(Function(w) w.Contains("a")).ToList()
words.Where(Function(w) w.Contains("a")).ToList()
The output is
{"apple", "banana", "date"}
.
The
Select()
function creates a new array that contains the results of applying a lambda expression to each element in the source array.
Assume you have a variable called
numbers
defined as Integer() = {1, 2, 3, 4, 5}
.
To get the list of numbers multiplied by themselves, apply the The output is
Select()
function as follows:numbers.Select(Function(n) n * n).ToArray()
numbers.Select(Function(n) n * n).ToArray()
{1, 4, 9, 16, 25}
.
The
Aggregate()
function performs calculations over all the elements in an array and returns a single value.
Assume you have a variable called
numbers
defined as Integer() = {1, 2, 3, 4, 5}
.
To get the sum of all the numbers in the array, apply the Aggregate() function as follows:The output is
Dim sum = numbers.Aggregate(Function(acc, n) acc + n)
Dim sum = numbers.Aggregate(Function(acc, n) acc + n)
15
.
The
GroupBy()
function groups elements in a sequence by a key selector function.
Assume you have a variable called
words
defined as String() = {"apple", "banana", "cherry", "date"}
.
To group the words by the first letter, which is the key selector function, apply the The output is
GroupBy()
function as follows:words.GroupBy(Function(w) w(0))
words.GroupBy(Function(w) w(0))
{ {"a", "apple", "date"}, {"b", "banana"}, {"c", "cherry"} }
.
The
OrderBy()
and OrderByDescending()
functions sort elements in a sequence based on a key selector function.
Assume you have a variable called
words
defined as String() = {"apple", "banana", "cherry", "date"}
.
To order the words by their length, which is the key selector function, apply the The output is
OrderBy()
function as follows:words.OrderBy(Function(w) w.Length).ToArray()
words.OrderBy(Function(w) w.Length).ToArray()
{"date", "apple", "cherry", "banana"}
.
The
Join()
function combines elements in two sequences based on a key selector function.
Assume you have two variables:
-
names
defined asString() = {"John", "Jane", "Joe"}
-
ages
defined asInteger() = {25, 30, 35}
To combine the elements in the first sequence with the elements in the second sequence, apply the The output is
Join()
function as follows:names.Join(ages, Function(name) name(0), Function(age) age Mod 10, Function(name, age) $"{name}: {age}")
names.Join(ages, Function(name) name(0), Function(age) age Mod 10, Function(name, age) $"{name}: {age}")
{"John: 25", "Jane: 30", "Joe: 35"}
.
The
First()
function returns the first element in a sequence that satisfies a specified condition.
Assume you have a variable called
numbers
defined as Integer() = {1, 2, 3, 4, 5}
.
To get the first even number in the sequence, apply the The output is
First()
function as follows:numbers.First(Function(n) n Mod 2 = 0)
numbers.First(Function(n) n Mod 2 = 0)
2
.
The
FirstOrDefault()
function returns the first element, or a default value if no element satisfies the condition.
Assume you have a variable called
numbers
defined as Integer() = {1, 2, 3, 4, 5}
.
To get the first odd number in the sequence, apply the The output is
FirstOrDefault()
function as follows:numbers.FirstOrDefault(Function(n) n Mod 2 = 1)
numbers.FirstOrDefault(Function(n) n Mod 2 = 1)
1
.
The
Last()
function returns the last element in a sequence that satisfies a specified condition.
Assume you have a variable called
numbers
defined as Integer() = {1, 2, 3, 4, 5}
.
To get the first even number in the sequence, apply the The output is
last()
function as follows:numbers.Last(Function(n) n Mod 2 = 0)
numbers.Last(Function(n) n Mod 2 = 0)
4
.
The
LastOrDefault()
function returns the last element, or a default value if no element satisfies the condition.
Assume you have a variable called
numbers
defined as Integer() = {1, 2, 3, 4, 5}
.
To get the first odd number in the sequence, apply the The output is
FirstOrDefault()
function as follows:numbers.LastOrDefault(Function(n) n Mod 2 = 1)
numbers.LastOrDefault(Function(n) n Mod 2 = 1)
5
.
The
Skip()
function skips a specified number of elements in a sequence.
Assume you have a variable called
numbers
defined as Integer() = {1, 2, 3, 4, 5}
.
To skip the first two elements in the sequence, apply the The output is
Skip()
function as follows:numbers.Skip(2).ToArray()
numbers.Skip(2).ToArray()
{3, 4, 5}
.
The
SkipWhile()
function skips elements until a condition is no longer satisfied.
Assume you have a variable called
numbers
defined as Integer() = {1, 2, 3, 4, 5}
.
To skip the numbers which are lower than 3, apply the The output is
SkipWhile()
function as follows:numbers.SkipWhile(Function(n) n < 3).ToArray()
numbers.SkipWhile(Function(n) n < 3).ToArray()
{3, 4, 5}
.
The
Take()
function returns a specified number of elements from the start of a sequence.
Assume you have a variable called
numbers
defined as Integer() = {1, 2, 3, 4, 5}
.
To get the first three elements in the sequence, apply the The output is
Take()
function as follows:numbers.Take(3).ToArray()
numbers.Take(3).ToArray()
{1, 2, 3}
.
The
TakeWhile()
returns elements until a condition is no longer satisfied.
Assume you have a variable called
numbers
defined as Integer() = {1, 2, 3, 4, 5}
.
To get the numbers which are lower than 4, apply the The output is
TakeWhile()
function as follows:numbers.TakeWhile(Function(n) n < 4).ToArray()
numbers.TakeWhile(Function(n) n < 4).ToArray()
{1, 2, 3}
.
The
Any()
function returns true
if any element in a sequence satisfies a specified condition.
Assume you have a variable called
numbers
defined as Integer() = {1, 2, 3, 4, 5}
.
To find out if at least one number in the sequence is even, apply the The output is
Any()
function as follows:numbers.Any(Function(n) n Mod 2 = 0)
numbers.Any(Function(n) n Mod 2 = 0)
true
.
The
All()
returns true
if all elements in a sequence satisfy a specified condition.
Assume you have a variable called
numbers
defined as Integer() = {1, 2, 3, 4, 5}
.
To find out if all the numbers in the sequence are positive, apply the The output is
All()
function as follows:numbers.All(Function(n) n > 0)
numbers.All(Function(n) n > 0)
true
.
The list function
AddItemToList()
adds a new item to an existing list.
Assume you want to manipulate the records in an Edit Grid control with data from a process integration, using the Set Value rule. The item to set is
Processes.ALLDATATYPES.out_genericList
.
To add an item to the generic list, assign it the following value:
AddItemToList(Processes.ALLDATATYPES.out_genericList, MainPage.EditGrid.NewItem)
AddItemToList(Processes.ALLDATATYPES.out_genericList, MainPage.EditGrid.NewItem)
The list function
DeleteItemFromList()
deletes items from an existing list.
Assume you want to manipulate the records in an Edit Grid control with data from a process integration, using the Set Value rule. The item to set is
Processes.ALLDATATYPES.out_genericList
.
To delete an item from the generic list, assign it the following value:
DeleteItemFromList(Processes.ALLDATATYPES.out_genericList, MainPage.EditGrid.RowIndex)
DeleteItemFromList(Processes.ALLDATATYPES.out_genericList, MainPage.EditGrid.RowIndex)
The list function
UpdateListItemAtIndex()
updates items in an existing list.
Assume you want to manipulate the records in an Edit Grid control with data from a process integration, using the Set Value rule. The item to set is
Processes.ALLDATATYPES.out_genericList
.
To update an item in the generic list, assign it the following value:
UpdateListItemAtIndex(Processes.ALLDATATYPES.out_genericList, MainPage.EditGrid.RowIndex, MainPage.EditGrid.SelectedItem)
UpdateListItemAtIndex(Processes.ALLDATATYPES.out_genericList, MainPage.EditGrid.RowIndex, MainPage.EditGrid.SelectedItem)
- VB function: Where
- VB function: Select
- VB function: Aggregate
- VB function: Group By
- VB function: Order By
- VB function: Join
- VB function: First
- VB function: First Or Default
- VB function: Last
- VB function: Last Or Default
- VB function: Skip
- VB function: Skip While
- VB function: Take
- VB function: Take While
- VB function: Any
- VB function: All
- VB function: Add item to list
- VB function: Delete item from list
- VB function: Update list item at index