Error 88: Invalid/Unknown property' on reference to a business object from within the same object

SOLVED

'Error 88: Invalid/Unknown property' on reference to a business object from within the same object
I am trying to browse the records in the 'SO_SalesOrderDetail' from within a Column Pre-Validate script on ItemCode in the same table'.
This works from a separate business object (e.g. SO_SalesOrder_bus), but I'm guessing there is a inability to do so from with the same object. Can someone confirm this?

oSO_SalesOrderDetail = oSession.GetObject("SO_SalesOrderDetail_svc") 'returns 100168
r = oScript.DebugPrint("oSO_SalesOrderDetail=" & oSO_SalesOrderDetail)

Set oSO_SalesOrderDetail = oSession.AsObject(oSO_SalesOrderDetail) 'Gets Error 88
r = oScript.DebugPrint("Set oSO_SalesOrderDetail=" & oSO_SalesOrderDetail) 


Parents
  • 0

    We just started getting this error within the last week or so on multiple button scripts that have been in service for years without issue. Sage 100 Adv 2020 (6.20.0.1). But it doesn't error on any specific line. It errors out at the start of the script. Pressing the button again allows the script to work without issue.

    This error occurs regardless where the script is set to run (both the server and client) and is highly inconsistent in the fact that first-clicks may not even generate an error. But so far it seems that once the error is displayed the script has always ran with a subsequent click.

    Viewing error detail shows 'Unable to run script'.

    While it's the same error, our cases don't really appear to be related. But I thought I'd share anyway just in case there is some other larger issue at work.

  • 0 in reply to SoonerFan21

    We need more details. Can you show the relevant code that led up to this error including the last method invoked?

  • +1 in reply to connex
    verified answer

    That's the problem. There are no methods invoked in my case. I could set a blank script to a button and it would still occasionally create this error at random. Some would go through and some won't - but those that don't will go through on a 2nd button click.

    The scripts are stored locally on the server running them so it can't be a network issue.

    It's almost like a file access permissions issue, but it's not. Even in the error screen the relevant script lines are displayed which shows that the server (from a server script) or the user (from a client script) both have permissions to read the file.

    In my case no portion of the script runs. The error occurs before ever reaching the first line.

  • 0 in reply to SoonerFan21

    How have you proven to yourself that no portion of the script runs before the error? With a Message box as the first line?

  • 0 in reply to connex

    Okay so I dug a bit deeper into trying to reproduce this issue. I may have been incorrect in my statement that this occurs on both client and server scripts as I can no longer get client-side scripts to produce this error in my limited testing since creating this post, but this is still unconfirmed.

    However, so far I have been able to reliably reproduce this issue when it comes to server-side scripts.

    Seems to occur on every script that is set to run on the server - but only after a client-side button script runs.

    Client -> Server = error

    Server -> Client = No Error

    Client -> Server [ERR] -> Client -> Server [ERR] -> [continues this pattern 100% of the time].

    This makes sense as in AR Cash Receipts Entry UI we have 2 button scripts, one that runs on the server to pull all available remaining cash to the 'PostingAmt' field (which runs on the server), which is a very simple script in itself:

    Then another button script that saves the currently-viewed PDF document open in Adobe to a server location (i.e. the customer's remittance advice that is to be tied to the deposit), which runs as a client-side script since it requires a reference to the client's Adobe object.

    ' Assign static base directory
    Const BaseDirectory	= "\\Filebox\Accounting\Memo Attachments\CashReceipts\"
    Const BaseLocalDir = "\\Filebox\users\"
    
    Dim BatchNo, DepositNo, CustomerName
    BatchNo			= AR_CashReceipts_bus_BatchNo
    DepositNo		= AR_CashReceipts_bus_DepositNo
    CustomerName    = AR_CashReceipts_bus_CustomerName
    
    ' Adobe-Related constants
    Const PDSaveBinaryOK		= &H10
    Const PDSaveCollectGarbage	= &H20
    Const PDSaveIncremental		= 0
    Const PDSaveFull			= 1
    Const PDSaveCopy			= 2
    
    ' Adobe Scripting objects
    Dim appAdobe, docAV, docPD
    Set appAdobe = CreateObject("AcroExch.App")
    Set docAV = appAdobe.GetActiveDoc
    Set docPD = docAV.GetPDDoc
    
    ' Query Objects
    Dim oDeposit, oBatch
    Set oDeposit	= New DEPOSITQRY
    Set oBatch		= New ACTIVEBATCHQRY
    
    ' Set server file path
    Dim dirServer, dirLocal, fileName, fileNameServer, fileNameLocal
    dirServer = VerifyFolder(BaseDirectory & BatchNo) & "\"
    
    ' Build local save directories
    With oDeposit
    
    	' Set file name
    	fileName = ValidFileName(DepositNo & " " & CustomerName & ".pdf")
    
    	Dim formattedDate
        formattedDate = Year( .DepositDate ) & "." & Pad2(Month( .DepositDate ))
    
    End With
    
    ' Save the documents
    docPD.Save PDSaveFull, dirServer & fileName
    
    InsertDB BatchNo, DepositNo, fileName
    
    Set docPD		= Nothing
    Set docAV		= Nothing
    Set appAdobe	= Nothing 
    
    
    Sub InsertDB(BatchNo, DepositNo, fileName)
        Dim sPathDB, sTblName, db, rs, sSQL, ArchiveSubfolder, conn
    
        ' Database path and table name
        sPathDB = "\\Filebox\Accounting\Memo Attachments\CashReceipts\Cash Receipts.mdb"
        sTblName = "Deposits"
    
        ' Create the ArchiveSubfolder string
        ArchiveSubfolder = Left(BatchNo, 3)
    
        ' Create database connection
        Set conn = CreateObject("ADODB.Connection")
    	conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sPathDB
    
        ' Check if the record exists
        sSQL = "SELECT * FROM " & sTblName & " WHERE BatchNo = '" & BatchNo & "' AND DepositNo = '" & DepositNo & "'"
        Set rs = conn.Execute(sSQL)
    
        If rs.EOF Then
            ' Record does not exist, so insert a new one
            sSQL = "INSERT INTO " & sTblName & " (BatchNo, DepositNo, Filename, ArchiveSubfolder) VALUES ('" & _
                   BatchNo & "', '" & DepositNo & "', '" & fileName & "', '" & ArchiveSubfolder & "')"
        Else
            ' Record exists, update it
            sSQL = "UPDATE " & sTblName & " SET Filename = '" & fileName & "', ArchiveSubfolder = '" & ArchiveSubfolder & "' " & _
                   "WHERE BatchNo = '" & BatchNo & "' AND DepositNo = '" & DepositNo & "'"
        End If
        conn.Execute sSQL
    
        ' Close the recordset and database connection
        rs.Close
        conn.Close
    
        ' Clean up
        Set rs = Nothing
        Set conn = Nothing
    End Sub
    
    Sub CopyFile(sFileSource, sDestination)
    	Dim fso:	Set fso = CreateObject("Scripting.FileSystemObject")
    	fso.CopyFile sFileSource, sDestination
    	Set fso = Nothing
    End Sub
    
    Function GetCommentDate()
    	With New RegExp
    		.Pattern = "^([\d.\/-]{3,8})|BANK A.*?([\d.\/-]{3,8})\]"
    		.IgnoreCase = True
    		Dim matches:	Set matches = .Execute(oBatch.Comment)
    		If matches.Count > 0 Then
    			Dim matchedDate
    			' Check which part of the pattern matched
    			If Len(matches(0).SubMatches(0)) > 0 Then
    			    matchedDate = matches(0).SubMatches(0)
    			Else
    			    matchedDate = matches(0).SubMatches(1)
    			End If
    			' Replace periods with slashes in the captured date, then convert
    			GetCommentDate = CDate(Replace(matchedDate, ".", "/"))
    		End If
    	End With
    End Function
    
    Function Pad2(sInput)
    	Pad2 = Right("0" & sInput, 2)
    End Function
    
    Function ValidFileName(sRawFileName)
        With New RegExp
            .Pattern = "[\/:*?""<>|\\]"
            .Global = True
            ValidFileName = .Replace(sRawFileName, " ")
        End With
    End Function
    
    Function VerifyFolder(sFolderPath)
    	'Conveniently returns the folderpath after creation to allow the check to happen when building path
    	With CreateObject("Scripting.FileSystemObject")
    		If Not .FolderExists(sFolderPath) Then
    			.CreateFolder sFolderPath
    		End If
    	End With
    	VerifyFolder = sFolderPath
    End Function
    
    Function UserName
    	UserName = CreateObject("WScript.Network").UserName
    End Function
    
    ' ====================================================
    ' =============== Script Class Objects ===============
    
    Class DEPOSITQRY
    	
    	Private sql
    	Private oConn	'As ADODB.Connection
    	Private oRS		'As ADODB.Recordset
    	
    	Public Sub QueryRefresh()
    		sql = "SELECT BankCode, BatchNo, DepositNo, DepositDate, DepositDesc, CreditDepositAmt FROM AR_CashReceiptsDeposit WHERE BatchNo='" & BatchNo & "' AND DepositNo='" & DepositNo & "'"
    		On Error Resume Next:	
    		If IsObject(oRS) Then oRS.Close
    		On Error GoTo 0
    		Set oRS = CreateObject("ADODB.Recordset")
    		oRS.Open sql, oConn
    	End sub
    
    	Public Property Get BankCode
    		BankCode = oRS("BankCode").Value
    	End Property
    	
    	Public Property Get DepositDate
    		DepositDate = oRS("DepositDate").Value
    	End Property
    	
    	Public Property Get DepositDesc
    		DepositDesc = oRS("DepositDesc").Value
    	End Property
    	
    	Public Property Get isCreditCard		
    		If CCur(oRS("CreditDepositAmt").Value) > 0 Then
    			isCreditCard = True
    		Else
    			isCreditCard = False
    		End If
    	End Property
    	
    	Private Sub Class_Initialize()
    		Set oConn = CreateObject("ADODB.Connection")
    		oConn.Open "DSN=SOTAMAS90-MVC"
    		QueryRefresh
    	End Sub
    	
    	Private Sub Class_Terminate()
    		rs.Close
    		conn.Close
    		Set rs = Nothing
    		Set conn = Nothing
    	End Sub
    	
    End Class
    
    Class ACTIVEBATCHQRY
    
    	Private sql
    	Private oConn	'As ADODB.Connection
    	Private oRS		'As ADODB.Recordset
    	
    	Public Sub QueryRefresh()
    		sql	= "SELECT BatchNo, Comment FROM GL_CompanyActiveBatch WHERE ModuleCode='A/R' AND BatchType='02' AND BatchNo='" & BatchNo & "'"
    		On Error Resume Next:	
    		If IsObject(oRS) Then oRS.Close
    		On Error GoTo 0
    		Set oRS = CreateObject("ADODB.Recordset")
    		oRS.Open sql, oConn
    	End sub
    
    	Public Property Get Comment
    		Comment = oRS("Comment").Value
    	End Property
    	
    	Private Sub Class_Initialize()
    		Set oConn = CreateObject("ADODB.Connection")
    		oConn.Open "DSN=SOTAMAS90-MVC"
    		QueryRefresh
    	End Sub
    	
    	Private Sub Class_Terminate()
    		rs.Close
    		conn.Close
    		Set rs = Nothing
    		Set conn = Nothing
    	End Sub
    	
    End Class

    But again, the code within the script doesn't matter, as I created client-side and server-side button scripts that points to a blank .vbs file and the pattern described earlier still continues. Here are two button scripts that point to the same blank script file, but one running on the server (E88 TEST - SVR) and the other running on the client.

  • 0 in reply to SoonerFan21

    What version of Sage 100 are you running?  64-bit or 32-bit?

  • 0 in reply to SoonerFan21

    OK, there are some known issues with scripts and 64-bit (and it looked exactly like that... blank script causing the error), but that won't apply if you are running 32-bit.

    Make sure you aren't running into machine specific AV restrictions on the Windows Scripting Host.  I recently had an old VBScript suddenly become flagged by our AV (Bitdefender)... as a false positive.

Reply
  • 0 in reply to SoonerFan21

    OK, there are some known issues with scripts and 64-bit (and it looked exactly like that... blank script causing the error), but that won't apply if you are running 32-bit.

    Make sure you aren't running into machine specific AV restrictions on the Windows Scripting Host.  I recently had an old VBScript suddenly become flagged by our AV (Bitdefender)... as a false positive.

Children
No Data