Removing a record from a table

Hi, I am trying to ‘loop’ over a sequence in Flow and the classic way of removing a processed record no longer works:


Can I make the record non-nullable (I created it with FirstOrNull from the AllocationsTbl)? How?
Or should I make the sequence nullable (I created it with the Create Table element)? How?

Thanks, Roel

Hello and thank you for the question!

First of all, I think the type checking is too strict here. There is no need for it to mark this as an error. We will change that.

But as for now, the way to make the record non-nullable is to null-check it. So, for for a workaround, you might wrap your expression in a case-when construct, i.e. {case when AllocationRec = null then AllocationsTable else AllocationsTable except AllocationRec end}.

A longer example which you can paste into the Flowscript playground:


// Create a table
let someRecords = [{a: 1, b: 2}, {a: 2, b: 3}];

// Create a record which exists in the table
let someRecord = {a: 1, b: 2};

// Same record, but on wednesdays it is null
let maybeSomeRecord = case when DateTime.getDayOfWeek(now()) == "wednesday"
                           then null
                           else someRecord
                           end;

// This displays the problem you mention:
//return someRecords except maybeSomeRecord;

// The workaround:
return case when maybeSomeRecord == null
            then someRecords
            else someRecords except maybeSomeRecord end;


If you’re creating a loop, why don’t you use First() instead of FirstOrNull()? Haven’t you already checked that the table contains data using a Decision step? Using First() avoids the error.

A second way to avoid the error is to remove the first record of the table with Skip()

let theTable = Skip(TheTable, 1);