Udostępnij za pośrednictwem


Retrieving a sales document number

To retrieve a Microsoft Dynamics GP sales document number, use the GetNextSopNumber method of the GetSopNumber class. To use the GetNextSopNumber method you specify the type of sale document, the document ID, and an eConnect connection string. The method returns the next available document number for the specified type of sales document.

The following Visual Basic example shows how to use the GetNextSopNumber method of the GetSopNumber class. Notice how the GetNextDocNumbers.SopType enumeration specifies the type of sales document. Also notice the use of STDINV as the document ID.

'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)