Hello all!
I'm working on a script to auto approve batches but I am running into some issues. I looked through the BOI course and there is an example in there that updates the SalesOrder so I adapted my code from that. I'm not sure if I'm setting it to the right module or not. I'm a little confused on if I should be updating the Receipt Register or the GL.
We run SAGE 100 MAS 90.
Below is the code I currently have.
oGLPost=""
Set oScript = CreateObject("ProvideX.Script")
oScript.Init("C:\sage\Sage 100 Advanced\MAS90\Home")
Set oSS = oScript.NewObject("SY_Session")
retVal = oSS.nLogon()
If retVal = 0 then
retVal = oss.nSetUser("user","password")
End If
retVal = oss.nSetCompany("TST")
retVal = oSS.nSetDate("P/O", "20200715")
retVal = oSS.nSetModule("P/O")
oGLUI = oSS.nSetProgram(oSS.nLookUpTask("PO_ReceiptRegister_UI"))
WScript.Echo oSS.sLastErrorMsg & "Line 17 PO UPDATE UI set"
Set oGLPost = oScript.NewObject("PO_ReceiptRegister_upd", oSS)
WScript.Echo "Line 20 PO UPD set"
' WScript.Echo "oGLPost set to new object"
If retVal = 0 Then
WScript.Echo oSS.sLastErrorMsg
'MessageBox.Show(oSS.sLastErrorMsg)
End If
retVal = oGLPost.nSelectBatch("07864")
WScript.Echo "Batch number set"
If CBool(oGLPost.nProcessReport("DEFERRED")) Then
retVal = oGLPost.nUpdate()
Select Case retVal
Case 0
WScript.Echo oGLPost.sLastErrorMsg
'MessageBox.Show(oGLPost.sLastErrorMsg)
Case 1
'MessageBox.Show("GL Updated Successfully!")
WScript.Echo "GL Updated Successfully!"
End Select
Else
'MessageBox.Show(oGLPost.sLastErrorMsg)
WScript.Echo oGLPost.sLastErrorMsg & "nProcessReport Else Statement Fired!"
End If
oGLPost.DropObject()