Is it possible to get the next voucher number for a payable transaction via DynamicsGPClient?
I can do a lookup but this voucher result is a few records old.
Dim PayablesInvoiceCriteria As New PayablesInvoiceCriteria() With {.Date = New BetweenRestrictionOfNullableOfdateTime() With {.GreaterThan = Date.now}}
Dim InvoiceSummaries As PayablesInvoiceSummary() = wsDynamicsGP.GetPayablesInvoiceList(PayablesInvoiceCriteria, context)
Dim Last = InvoiceSummaries(InvoiceSummaries.Length - 1).Key.Id
A bit of info on how the key generation works for transactions in GP. The keys are saved in PM00400 table, and they are created/generated when a user starts a transaction. They become "permanent" in the keys table when the user saves the record. So the behavior you are seeing is probably related to that process.
I am not sure if this can be done without eConnect. So my suggestion, as a workaround, you can use the eConnect namespace.
https://msdn.microsoft.com/en-us/library/ff623620.aspx
Class
Microsoft.Dynamics.GP.eConnect.GetNextDocNumbers
Syntax
public virtual string GetPMNextVoucherNumber(
GetNextDocNumbers.IncrementDecrement incDec,
string connString
)
Example
Dim connString as String = string.Empty
Dim sqlserver as String = "localhost"
Dim database as String = "TWO"
connString = "data source=" + sqlserver + ";" + "initial catalog=" + database + ";" + "Integrated Security=SSPI;"
Dim NextDocNumber as New String
Dim getNextDocNumbers = new Microsoft.Dynamics.GP.eConnect.GetNextDocNumbers()
NextDocNumber = getNextDocNumbers.GetPMNextVoucherNumber(Microsoft.Dynamics.GP.eConnect.IncrementDecrement.Increment, connString)
Additional examples can be found here: