function getNextRECID(grid){

    // make sure all the gui entries are already in the records array. That makes the red flags in the grid boxes go away as an additional result
    grid.save()

    if(grid.records.length < 1) {
        return 1
    }

    var highest = 1;

    for(var i=0; i< grid.records.length;i++){

        var recid = grid.records[i].recid
        if(recid>highest) highest=recid

    }
    // return an id one higher then the existing highest
    return highest+1
}
Returns the next useable recid for a grid. A bit clunky this workaround but needed for w2ui
@param grid - W2ui Grid object