Unable to drop object in event script

I have a working event script tied to S/O detail that fires on post validation of quantity ordered.  The script automatically creates a BOM Production Entry for the item entered, updates the production entry and updates the GL DTR.  The problem I'm having is that you must close sales order completely to have it release my DTR object.  Even if you accept the order and go back to the blank data entry screen you still see the B/M DTR in use.  Once you close S/O entry the B/M DTR task is released.  Below is my code related to grabbing the GL_DailyTransaction_Upd object and updating it.  I've tried setting my object variable to NOTHING, Clear(), etc and nothing seems to work.  Any ideas?

r = oSession.SetModule("B/M")
'msgbox("Set Module " & r)

r = oSession.SetDate("B/M", 20220104)
'msgbox("Set Date " & r)

r = oSession.SetProgram(oSession.LookupTask("GL_DailyTransactionUpdate_UI"))
'msgbox("Set Task " & r)

SET oGL_DTR = oSession.AsObject(oSession.GetObject("GL_DailyTransaction_upd"))
		'msgbox("DTR UPD Handle" & retVal)
	r = oGL_DTR.SetUpdateRegister(CurReg)   'UpdRegNo
		'msgbox("Register set? " & r & " ; Last Error:  " & gl.LastErrorMsg)
	r = oGL_DTR.ProcessReport("PREVIEW")
		'msgbox("Process Report " & gl.LastErrorMsg)
	r = oGL_DTR.Update()

Parents Reply
  • in reply to FormerMember

    ...or SET objectname = nothing

    Also, it is never recommended to post from Preview... you skip Paperless Office that way.

    Why not just explode the kit items instead of auto-processing the Production Entry?  Seems to me like that would be easier, without scripting, handling quantity changes much better too.

Children
  • in reply to Kevin M

    I did try setting the object to nothing and unfortunately that didn't resolve it either.  It's a bit maddening because the normal cleanup methods I've used in the past don't work.

    As for using Kits, unfortunately the script is replacing a mod and the functionality has to remain the same.