This sample script get the product if exist if not it adds new record.
Script Trigger OnObjectExit
Perform this script
The Find Peform Above is as follows Products::ProductCode=$theCode
Many thanks. Worked fine
I suggest using OnObjectSave instead of onObjectExit. There's no need to perform the script if you click into the field then out of it without changing the data in the field.
You might also want to open a custom dialog that asks the user if they want to create a new product record before actually creating a new record--they may have mistyped a value and just want to cancel out of the new product option so that they can fix their data entry error.