Breakout script to process a single sales order.

Discussions relating to breakout scripting, .NET and COM programming with Jiwa objects.

Breakout script to process a single sales order.

Postby Mike.Sheen » Fri Aug 15, 2008 3:56 pm

Here's a little breakout script to process a single sales order - this example works from within the sales order form, but could easily be modified to work from anywhere.

Code: Select all
' Form Loaded breakout
End Sub

Public Function ProcessSalesOrder(FormObject, SalesOrderObject)
Dim SOProcObject
Dim lErrorString
Dim lErrorModule
   
    ProcessSalesOrder = True
   
    If ProcessSalesOrder = True Then
        Set SOProcObject = CreateObject("JiwaProcessSO.clsSalesOrderProcess")
        Set SOProcObject.Database = SalesOrderObject.Database
        Set SOProcObject.CommonLib = SalesOrderObject.JiwaCommLib
        Set SOProcObject.JLib = SalesOrderObject.JLib
        Set SOProcObject.MDIParent = FormObject.MDIParent
        Set SOProcObject.SystemProfile = SalesOrderObject.SystemProfile
    End If
   
    If ProcessSalesOrder = True Then
        If SOProcObject.Setup = 0 Then
            ProcessSalesOrder = False
            lErrorString = SOProcObject.ErrorString
            lErrorModule = SOProcObject.ErrorModule
        End If
    End If
   
    If ProcessSalesOrder = True Then
        If SOProcObject.ProcessSalesOrder(SalesOrderObject.InvoiceID) = 0 Then
            ProcessSalesOrder = False
            lErrorString = SOProcObject.ErrorString
            lErrorModule = SOProcObject.ErrorModule
        End If
    End If
           
    If Not (SOProcObject Is Nothing) Then
        SOProcObject.CleanUp
        Set SOProcObject = Nothing
    End If
   
    If ProcessSalesOrder = False Then
        MsgBox "Error occurred whilst processing : " & lErrorString & vbCrLf & "Module : " & lErrorModule
    End If
       
End Function


You could then invoke this, when the sales order invoice is printed
Code: Select all
' Sales Order Save Completed Breakout
If Printing = True And SalesOrderObject.SalesOrderStatus = 0 Then
    If SalesOrderObject.PrintLogs(SalesOrderObject.PrintLogs.Count).ReportType = 0 Then
        If ProcessSalesOrder(FormObject, SalesOrderObject) = True Then
            FormObject.ReadRecord 0
        End If
    End If
End If
End Sub
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Return to Technical / Programming

Who is online

Users browsing this forum: No registered users and 7 guests