Create Item on SO from Button Script

SOLVED

Experts,

I have a button script that generates an item code. The generated item code does not yet exist in CI_Item. The desired behavior is that I can populate the new ItemCode on a new line in SO Entry and from there default Sage logic takes over (user gets asked if this is a new item or an alias).

Is there a way to accomplish this? I am not sure how I can get the data into the field without saving the line. And I can't save the line because the item doesn't exist yet.

Thanks,


Bastian