I use the same script on OnBeforeUpdate and OnBeforeInsert events.
In both cases I have Error “Invalid Item!”, but on onBeforeInsert I have also additional Error “Undefined offset: 0”.
Below is the script I used.
sc_lookup(dataset, “select arbecd from CWMUDTA.initem where arcomp={M0COMP} and arbecd=’{M0ITEM}’”);
if (!{dataset[0][0]})
{
sc_error_message(“Invalid Item!”);
}