Table

Create table and insert/update/delete rows

Create Table: The empty table statement

Sometimes it is necessary to create an empty table, containing only column names but no rows. This can be done by creating a Table Item with no rows in the workflow or using a FlowScript expression.

let emptyOrderList = table(orderNo, price, isConfirmed);

Converting a record to a table

To convert a record into a table, use the multiplier (*) unary operator.

let myTable = *myRecord;
let myOtherTable = *[a: 1, b: 2];

Insert row: The table concatenation (&) operator

You can append a record to a table, or append a table to another table, using the & operator. The left hand side value (L) of the expression must be a table. The right hand side value (R) can either be a record or another table. R must contain all the columns/fields of L. Any fields/columns present in L but not R will be excluded from the output.

let newOrderList = orders & selectedOrder;
let allOrders = localOrders & centralOrders;
let orders = orders & [orderNo: orderNo, partNo: partNo, qty: qty];

Update row: The WITH Keyword

WITH (described above) is also supported when working with tables. The example below updates the price column with new values. Note that all table mutation is non-destructive; in the example below, items is left unchanged while newItems contains the updated rows.

let newItems = items with [price: price * 1.03];

It is also possible to update only a subset of the rows in a table by appending a WHERE clause to the end of the WITH expression. A new table is returned with the mutation selectively applied to the rows that match the WHERE criteria.

let newItems = items with [price: price * 0.7] where qtyInStock > 100;

Delete rows: The EXCEPT Keyword

If you need to remove a record from a table (creating a new table variable with the record excluded), use the EXCEPT keyword. The except keyword takes a table on the left hand side and a record on the right hand side. Each row of the table is examined and compared to the record. Rows in which every named cell also present in the record is equal to the record's cell are excluded from the output. This means that the EXCEPT keyword can remove more than one row; if two duplicate rows exist in the table, or if the record to remove has fewer fields than the table, more than one table row may match the record.

let otherOrdersEx1 = orders except selectedOrder;
let otherOrdersEx2 = orders except [orderNo: 'ABC1234'];

Delete rows: The EXCEPT WHERE Keyword

Sometimes a filtering expression becomes more readable if the logic is inversed. The EXCEPT WHERE keyword does the opposite of the WHERE keyword: it returns a new table excluding (rather than including) the rows matching the right hand side condition.

let valuableOrders = orders except where price = 0;

Last updated