SO_SalesJournal_upd - 'The register must be printed prior to posting'

So my trials with this update object continue.  I have a console application that simply prints to paperless/updates the SO Sales Journal for any and all SO Invoice batches available.  Program works fine when running it manually - prints all necessary reports/journals to paperless, updates the sales journal, does the same for the resulting DTR. (Sage 100 2020.1 Premium)

I add it to the windows task scheduler as a basic task to run once a day at particular time and, whether it runs on schedule or is manually invoked, it prints the Sales Journal to paperless office (along with all other additional reports I enabled - GP journal, etc). HOWEVER -

Immediately upon calling the below method, it fails and returns 'The register must be printed prior to posting'.  If I check paperless office, the resulting PDF is there, in its completion, but shows 'N' as updated.

oUpdObj.nUpdate()

This is ONLY limited to running it using task scheduler.  Task scheduler is set to run as domain admin, with highest privileges, etc.

Just curious if anyone has come across this or may have any suggestions!  At this point I'm ready to give up ;(

Parents
  • have you used the same domain admin account used to run the task to update the register at least once through the sage 100 desktop?

    At one point, I recall various forms/reports had to be printed/previewed by a user at least once before it could be automated by a BOI script.

  • in reply to David Speck

    Thanks for the suggestion David, but same result Disappointed.    In addition, the last couple of times it failed, it failed with 'The status of one or more batches has changed. Verify the current status and try again.'  Upon checking/verifying the batches, there were not changes.   In the end, the problem seems to reside somewhere in the context of running the application via scheduled task, as running the program manually ends in success every time.

  • in reply to Justin K

    Below is some code from one of my journal update scripts that goes through paperless office.  Try comparing methods I used to methods you are using.

    RetVal = 0 : SY_Session.sLastErrorMsg = "" : RetVal = SY_Session.nSetProgram(SY_Session.nLookupTask("BM_ProductionRegister_UI"))
    If RetVal <> 0 Then
    	Set BM_ProductionRegister_Upd = SY_Session.oNewObject("BM_ProductionRegister_Upd")
    	RetVal = 1
    	If BM_ProductionRegister_Upd.nBatchEnabled <> 0 Then 
    		RetVal = 0 : BM_ProductionRegister_Upd.sLastErrorMsg = "" : RetVal = BM_ProductionRegister_Upd.nSelectBatch(DestinationBatchNo)
    		If ArgDebugPrint Then oScript.DebugPrint "nSelectBatch: " & RetVal & " | " & "LastErrorMsg: " & BM_ProductionRegister_Upd.sLastErrorMsg
    	End If
    	BM_ProductionRegister_Upd.nPDFSilent = 1
    	BM_ProductionRegister_Upd.nSetPostingDate ModuleDate
    	RetVal = 0 : BM_ProductionRegister_Upd.sLastErrorMsg = "" : RetVal = BM_ProductionRegister_Upd.nProcessReport("PRINT")
    	If ArgDebugPrint Then oScript.DebugPrint "nProcessReport: " & RetVal & " | " & "LastErrorMsg: " & BM_ProductionRegister_Upd.sLastErrorMsg
    	If RetVal = 1 Then
    		RetVal = 0 : RetVal = BM_ProductionRegister_Upd.nEndOfPDFConverterJob()
    		RetVal = 0 : RetVal = BM_ProductionRegister_Upd.nUpdate()
    		If ArgDebugPrint Then oScript.DebugPrint "nUpdate: " & RetVal & " | " & "LastErrorMsg: " & BM_ProductionRegister_Upd.sLastErrorMsg
    		If RetVal <> 0 Then UpdateDailyTransactionRegister = True
    	End If
    End If

Reply
  • in reply to Justin K

    Below is some code from one of my journal update scripts that goes through paperless office.  Try comparing methods I used to methods you are using.

    RetVal = 0 : SY_Session.sLastErrorMsg = "" : RetVal = SY_Session.nSetProgram(SY_Session.nLookupTask("BM_ProductionRegister_UI"))
    If RetVal <> 0 Then
    	Set BM_ProductionRegister_Upd = SY_Session.oNewObject("BM_ProductionRegister_Upd")
    	RetVal = 1
    	If BM_ProductionRegister_Upd.nBatchEnabled <> 0 Then 
    		RetVal = 0 : BM_ProductionRegister_Upd.sLastErrorMsg = "" : RetVal = BM_ProductionRegister_Upd.nSelectBatch(DestinationBatchNo)
    		If ArgDebugPrint Then oScript.DebugPrint "nSelectBatch: " & RetVal & " | " & "LastErrorMsg: " & BM_ProductionRegister_Upd.sLastErrorMsg
    	End If
    	BM_ProductionRegister_Upd.nPDFSilent = 1
    	BM_ProductionRegister_Upd.nSetPostingDate ModuleDate
    	RetVal = 0 : BM_ProductionRegister_Upd.sLastErrorMsg = "" : RetVal = BM_ProductionRegister_Upd.nProcessReport("PRINT")
    	If ArgDebugPrint Then oScript.DebugPrint "nProcessReport: " & RetVal & " | " & "LastErrorMsg: " & BM_ProductionRegister_Upd.sLastErrorMsg
    	If RetVal = 1 Then
    		RetVal = 0 : RetVal = BM_ProductionRegister_Upd.nEndOfPDFConverterJob()
    		RetVal = 0 : RetVal = BM_ProductionRegister_Upd.nUpdate()
    		If ArgDebugPrint Then oScript.DebugPrint "nUpdate: " & RetVal & " | " & "LastErrorMsg: " & BM_ProductionRegister_Upd.sLastErrorMsg
    		If RetVal <> 0 Then UpdateDailyTransactionRegister = True
    	End If
    End If

Children
  • in reply to David Speck

    Thanks David.  There are definitely some extra methods being called/properties being set in your example that I don't have in place.  It's a little concerning to me that the program will work fine when run manually and that I have the same program working successfully at another client via scheduled task, but whatever works!.  Will let you know how I make out.

  • in reply to Justin K

    Paperless office plays a part in this.  I recall at one point, you had to modify the pvx.ini file to contain the [Paperless] section from another file in order for paperless office to work with external BOI scripts.  Can't recall off the top of my head if that is still required on 2019+.

    If you were calling ProcessReport with "EXPORT" instead of "PRINT" then you would handle the file path and format yourself but it would bypass paperless office so whenever possible if paperless office is configured, I want to leverage it.

    There are a lot of things that comes into play with Windows Task Scheduler too, such as the account used to run it, whether you have the option checked to run whether or not the user is logged in, NTFS permissions of the Sage 100 MAS90 directory, Advanced vs Standard, etc.