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];

Download an example workflow from the Flow community (here)[http://community.novacuraflow.com/product/internal-table-example-flow/]. Observe that you need to log in to the Flow commnuity to be able to download the workflow

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.

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

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