Interactive grid - add next index to record

Interactive Grid - add next index to record.

First give the column you want to update a static id such as

C_INDEX.

Define a hidden page item to hold the next index value.

P5_NEXT_INDEX.

Create the DA on the IG region and give it a name.
When:
Event: Row Initialization Selection
Type:
RegionRegion: your IG regionThen

Add an Execute JavaScript Code action with this:

var index;
var model = this.data.model;
var meta = model.getRecordMetadata(this.data.recordId);
if ( meta.inserted && !meta.updated ) {    index = $v("P5_NEXT_INDEX");
$s("C_INDEX", index);
index += 1;
$s("P5_NEXT_INDEX", index);
}