If you don't mind a mix of vbscript and provideX, you could try out the routines in the two attached files. Have them both in CM\Script.
The vbs file needs to be assigned to a business object's event, such as the SO_SalesOrderDetail Pre-Validate event on the QuantityOrdered column. It then calls the providex in the pvc file using the entry label ""loop_through_detail"". The pvc file simply ""returns"" to the vbs file using the ""return"" statement. If you actually want to handle things differently, you could substitute the ""return"" with ""exit x"" where x is is a number which if anything other than -1 will trigger an ""Execute Error x"" in the vbs file. You just have to have an ""On Error Resume Next"" immediately before the line and you can always put ""On Error GoTo 0"" after the line. If you need to get values in between the two scripts, you can either use the SetVar methods of the oScript object or use global provideX variable names which are prefixed with ""%"". For example, in the vbs file, you could set a global variable like this.
oScript.Execute(""%myGlobalVariable$=""""Test"""")
In the pvc, you would just refer to the variable by name.
coSession'UI'MessageBox$("""", %myGlobalVariable$)
OR
%myGlobalVariable$=""Test""
To get the value of a provideX variable in the vbs script, you use the following.
sGlobalVariable = """"
sGlobalVariable = oScript.Evaluate(""%myGlobalVariable$"")
You just have to remember when dealing with provideX that anything string related needs to have the ""$"" at the end. You cannot, for example, use the following.
%myGlobalVariable$=5
Also %myGlobalVariable$ and %myGlobalVariable are two different variables as far as provideX is concerned.
If you are really curious, i also attached the ProvideX documentation which you might find useful if you pursue this.