I have a method in a Dynamics GP Addin. The method is suppose to substitute accounts based on a the client's account pattern.
When I issue a ChangeNext() command, I get back "DoubleLock" as the return value; but only the second time I issue the command. I understand that this means that I have attempted to lock a record that has already been locked. How do I unlock that record? Issuing Release() on the table prior to executing the command does nothing. How do I unlock a record in GP
private void UpdateInvoiceLineWork(string invoiceNumber, Dictionary < int, int > replacements) {
if (!String.IsNullOrEmpty(invoiceNumber)) {
IvcLineWorkTable _lineWork = Dynamics.Tables.IvcLineWork;
_lineWork.Release();
_lineWork.Key = 5; //select key group five, which allows us to use just the invoice number
_lineWork.Clear();
_lineWork.InvoiceNumber.Value = invoiceNumber;
_lineWork.RangeStart();
_lineWork.Clear();
_lineWork.InvoiceNumber.Value = invoiceNumber;
_lineWork.RangeEnd();
TableError _result = _lineWork.ChangeFirst();
if (_result == TableError.NoError) {
do {
string _itemNumber = _lineWork.ItemNumber.Value;
if (replacements.ContainsKey(_lineWork.CostOfSalesIndex.Value)) {
_lineWork.CostOfSalesIndex.Value = replacements[_lineWork.CostOfSalesIndex.Value];
_lineWork.Save();
}
_result = _lineWork.ChangeNext();
}
while (_result == TableError.NoError);
}
_lineWork.Close();
}
}