Void a Check

Top  Previous  Next

[Visual Basic] The following example demonstrates how to Void an existing Check document. (This example uses the CheckWebService.)

 

' ----------------------------------------

' Step 1: Create an instance of the web service.

' ----------------------------------------

Dim checkWs As New WebServices.CheckWebService("http://localhost/objacctwebservices/")

 

' ----------------------------------------

' Step 2: Set the LoginKey. (Use Login.GetLoginKey to

' login to a specific company and generate a LoginKey.)

' For this example, the LoginKey is being stored in a 

' public variable called PublicLoginKey.

' ----------------------------------------

StdLib.PopulateObjAcctSoapHeader(checkWs, PublicLoginKey)

 

' ----------------------------------------

' Step 3: Create and populate a DataSet with the existing document.

' For this example, we're voiding a Check document, so we

' will use the ObjAcct.WebServices.DataSets.CheckDataSet.

' ----------------------------------------

Dim checkDs As DataSet = New WebServices.DataSets.CheckDataSet()

Dim DocID As String = "CK5000"

 

' Retrieve the Check document.

checkDs = checkWs.GetDocumentByDocumentID(DocID, COMPANYSETUP("APPaymentAccountRowID"), "", "", ReturnTypeEnum.Standard)

 

' Check for errors.

If StdLib.GetErrorNumber(checkDs) < 0 Then

       MsgBox(StdLib.GetErrorAsString(checkDs))

Else

       ' ----------------------------------------

       ' Step 4: Create an instance of the web service.

       ' ----------------------------------------

       Dim voidCheckWs As New WebServices.CheckWebService("http://localhost/objacctwebservices/")

 

       ' ----------------------------------------

       ' Step 5: Set the LoginKey. (Use Login.GetLoginKey to

       ' login to a specific company and generate a LoginKey.)

       ' For this example, the LoginKey is being stored in a 

       ' public variable called PublicLoginKey.

       ' ----------------------------------------

       StdLib.PopulateObjAcctSoapHeader(voidCheckWs, PublicLoginKey)

 

       ' ----------------------------------------

       ' Step 6: Set the Document RowID, Document Type RowID and Void Date.

       ' ----------------------------------------

       Dim documentRowID As String = checkDs.Tables("Header").Rows(0).Item("RowID").ToString.Trim

       Dim documentTypeRowID As String = checkDs.Tables("Header").Rows(0).Item("JournalDocTypeRowID")

       Dim voidDate As String = Today.ToShortDateString

 

       ' ----------------------------------------

       ' Step 7: Void the Check document.

       ' ----------------------------------------

       Dim returnDs As DataSet = voidCheckWs.VoidDocument(documentRowID, documentTypeRowID, voidDate)

 

       ' Check for errors.

       If StdLib.GetErrorNumber(returnDs) < 0 Then

               MsgBox(StdLib.GetErrorAsString(returnDs))

       End If

End If