title: Release Invoice and Inventory Issue in code
body: <p>I have a routine to release an invoice and post to inventory that worked in v6.1.  I think it was working in 2017R2 also, but I don't know for sure.  It does not seem to work at all in 2018R1.  The invoice releases, but the inventory issue is not released.  The automations are all set to automatically release the issue and they work when processed manually.  Only my code does not release the issue.  I am at a loss as to why.  Any ideas?</p>
  
  <p>============================================================</p>
  
  <p>I have updated the code to the latest version based on your suggestions, but the inventory issue is still not released.</p>
  
  <pre><code>foreach (EDASNShipment asnShipment in PXSelect&lt;EDASNShipment,
      Where&lt;EDASNShipment.aSNNbr, Equal&lt;Required&lt;EDASN.aSNNbr&gt;&gt;&gt;&gt;.Select(this, asn.ASNNbr))
  {
      soShipmentGraph.Clear();
      SOShipment soShipment = soShipmentGraph.Document.Search&lt;SOShipment.shipmentNbr&gt;(asnShipment.ShipmentNbr);
      var soShipmentExt = PXCache&lt;SOShipment&gt;.GetExtension&lt;SOShipmentExt&gt;(soShipment);
  
      SOOrderShipment soOrderShipment = PXSelect&lt;SOOrderShipment,
          Where&lt;SOOrderShipment.shipmentNbr, Equal&lt;Required&lt;SOOrderShipment.shipmentNbr&gt;&gt;&gt;&gt;.Select(this, asnShipment.ShipmentNbr);
  
      ARInvoice arInvoice = PXSelect&lt;ARInvoice, Where&lt;ARInvoice.refNbr, Equal&lt;Required&lt;ARInvoice.refNbr&gt;&gt;,
          And&lt;ARInvoice.docType, Equal&lt;Required&lt;ARInvoice.docType&gt;&gt;&gt;&gt;&gt;.Select(this, soOrderShipment.InvoiceNbr, "INV");
      if (soShipment.Status != "C")
      {
          if (autoReleaseInvoices)
          {
              if (arInvoice != null)
              {
                  /*
                  soInvoiceGraph.Clear();
                  soInvoiceGraph.Document.Current = arInvoice;
                  soInvoiceGraph.release.Press();
                  var a = new PXAdapter(soShipmentGraph.Document)
                  {
                      Searches = new object[] { soShipment.ShipmentNbr }
                  };
                  //Note: Post Invoice to IN is Action 3 
                  a.Arguments.Add("actionID", 3);
                  a.MassProcess = false;                       //Don't pop up invoice screen
                  a.MaximumRows = 1;
                  PXLongOperation.StartOperation(this, () =&gt;
                  {
                      foreach (SOShipment shipment in soShipmentGraph.action.Press(a))
                      {
                          shipment.ShipmentNbr = shipment.ShipmentNbr;
                      }
                  });
                  */
  
                  //Release Invoice
                  PXLongOperation.StartOperation(this, delegate ()
                  {
                      soInvoiceGraph.Clear();
                      soInvoiceGraph.Document.Current = arInvoice;
                      soInvoiceGraph.release.Press();
  
                      //Update IN on Shipment
                      soShipmentGraph.Clear();
                      soShipmentGraph.Document.Current = 
                              soShipmentGraph.Document.Search&lt;SOShipment.shipmentNbr&gt;(asnShipment.ShipmentNbr);
                      soShipmentGraph.UpdateIN.Press();
                  });
              }
              else
              {
                  statusText += String.Format("Acumatica Invoice could not be located: {0}  ", soOrderShipment.InvoiceNbr);
                  errorOccurred = true;
                  bolAtLeastOneError = true;
              }
          }
      }
      soShipmentGraph.Clear();
      soShipment = soShipmentGraph.Document.Search&lt;SOShipment.shipmentNbr&gt;(asnShipment.ShipmentNbr);
      soShipmentExt = PXCache&lt;SOShipment&gt;.GetExtension&lt;SOShipmentExt&gt;(soShipment);
      soShipmentExt.UsrEDIStatus = "S";       //Sent
      soShipmentGraph.Document.Update(soShipment);
      soShipmentGraph.Persist();
  }
  </code></pre>