Search the GP Tables
Search by TABLE NAME
Search by FIELD NAME
These are our SOP scripts. All of our scripts for Dynamics GP can be found here
DynDeveloper.com

DynDeveloper.com

Table Edits Forum Articles
Table Edits 0 Table Edits 0 Table Edits 0
Sign Up Now!Log In
kurtnelle 9/6/2017 5:30:28 PM

DoubleLock error

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();

 }
}
Version: GP 2015
Section: .NET Development








Table Definition Quick Links
All Tables
SOP Tables
RM Tables
GL Tables
POP Tables
HR Tables
PM Tables
UPR Tables
IV Tables
Olympic Tables