How to detect a row is a newly inserted row

Current solution is

  • add a virtual column name TempKey which is set identical to a table’s key named _Key. Set the column as a reference column which will point back to the current table
  • add another virtual column named isNew in which we check the TempKey reference. E.g ISBLANK([TempKey].[_Key]). If the column is true, the current row is brand new.

Is there better way to detect the newly-inserted row? What’s your trick?
Thanks in advance for sharing.

Note - we use the information to make some columns editable at the insertion state or at re-editing state.

Solved Solved
0 11 1,470
1 ACCEPTED SOLUTION

Good to know that.

View solution in original post

11 REPLIES 11

Steve
Platinum 4
Platinum 4

To use in a form to determine if the row is new:

IN([_ROWNUMBER], table-name[_ROWNUMBER])

Or:

I thought about using filter or checking row number list but could they be slower?

Honestly, I don’t know the performance impact of using a virtual column.

Depending on what sort of expression you kick into Virtual Column, but IN() expression is one of heavy expression.
If you use with small amount of data set, no obvious impact (slownesss) you may feel, but once the data set grows, it will slow down the app.

After IN expression, Select expression is generally expensive as well.

The virtual column is simple duplication of the key. Say _ComputedKey is the key. Then the virtual column will have the formula [_ComputedKey] and then reference back to the same table.

Sounds like a self-ref type of arrangement, it should not be a heavy operation then.

@Steven_Aung Why would you need to have a virtual column for this purpose at all? If you use the IN() expression with the Editable If, it has nothing to do with performance because it’s recalculated only when you edit the record.

I see. The reason was that the editable calculation is shared by multiple columns.

It doesn’t matter if one or more columns are involved. You just need to create a suitable formula for your Editable option.

Good to know that.

@Steve @Aleksi 

I'm assuming this works with the use of recursion / looping to create records within a form that calls a group action?  I have a scheduler that generates 1 to N "Schedules".  The form "saved event" calls a looping group action (capped at 5).  My concern is when users edit these generated records, it will (a) be taxing on the system to see if the record exists (n times) and (b) it will not recognize this as an edit and duplicate records.

Thoughts on this approach?  any better ideas to place this?  Otherwise I'll just break up the function into different slices/views.  Edit Mode / Schedule mode.  

Thanks!

Matt

Your approach is fine, it's how I do it, and there's really no other way to do it.

Top Labels in this Space