Index was outside the bounds of the array in Data Directive Custom Code on UD100

here is a link to the latest way to get next id.