Returning a sales document number

To return an unused Microsoft Dynamics GP sales document number, you use the RollBackSopNumber method of the GetSopNumber class. To use the RollBackSopNumber method you specify the document number, the type of sale document, the document ID, and an eConnect connection string.

The following Visual Basic example shows how to use the RollBackSopNumber method of the GetSopNumber class to return an unused sales invoice document number. Notice how the GetSopNumber class is used to first retrieve the sales invoice document number. Also notice the use of STDINV as the document ID when the document is retrieved and when it is returned.

'Create a connection string that connects to the TWO database on
the local
‘ computer
Dim connectionString As String
connectionString = "Data Source=localhost;Integrated
Security=SSPI;" _
	& "Persist Security Info=False;Initial Catalog=TWO;"

'Instantiate a GetSopNumber object
Dim getSopNumber As New GetSopNumber

'Get the next available sales invoice document number
Dim salesInvoiceNumber As String
salesInvoiceNumber = getSopNumber.GetNextSopNumber( _ 
	GetNextDocNumbers.SopType.SOPInvoice, _
	"STDINV", connectionString)

'Return the sales invoice number to Microsoft Dynamics GP
Dim returnSucceeded =
getSopNumber.RollBackSopNumber(salesInvoiceNumber, _ 
	GetNextDocNumbers.SopType.SOPInvoice, _
	"STDINV", connectionString)

Documentation Feedback