3

We have requirement to make Ext. Price editable even after the invoice is released, we wrote logic to make field editable but when we update value we are getting "Project cannot be empty error". We are using Acumatica 2020 R2 Build - 20.207.0012 with Sales Demo database and without any customizations.

Here is a code sample:

   private bool IsDisabled(ARInvoice doc)
        {
            return doc.Released == true
                || doc.Voided == true
                || doc.DocType == ARDocType.SmallCreditWO
                || doc.PendingPPD == true
                || doc.DocType == ARDocType.FinCharge
                && !Base.IsProcessingMode
                && Base.Document.Cache.GetStatus(doc) == PXEntryStatus.Inserted;
        }
          
    protected void ARInvoice_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
    {
      if(InvokeBaseHandler != null)
        InvokeBaseHandler(cache, e);
      var rows= (ARInvoice)e.Row;

       if (rows == null)
                return;

            if (IsDisabled(rows))
            {
              PXUIFieldAttribute.SetEnabled<ARTran.curyExtPrice>(cache, rows, true);

                Base.Document.Cache.AllowUpdate = true;
                Base.Transactions.Cache.AllowUpdate = true;
              }
      
    }

Trace:

3/16/2021 12:30:41 PM Error:
Error: Updating  'SO Invoice' record raised at least one error. Please review the errors.

Error: 'Project' cannot be empty.

   at PX.Data.PXUIFieldAttribute.CommandPreparing(PXCache sender, PXCommandPreparingEventArgs e)
   at PX.Data.PXCache.OnCommandPreparing(String name, Object row, Object value, PXDBOperation operation, Type table, FieldDescription& description)
   at PX.Data.PXProjectionAttribute.PersistUpdated(PXCache sender, Object row)
   at PX.Data.PXCache`1.PersistUpdated(Object row, Boolean bypassInterceptor)
   at PX.Data.PXCache`1.Persist(PXDBOperation operation)
   at PX.Data.PXGraph.Persist(Type cacheType, PXDBOperation operation)
   at PX.Data.PXGraph.Persist()
   at PX.Objects.AR.ARInvoiceEntry.Persist()
   at PX.Objects.AR.ARInvoiceEntryExternalTax.Persist(Action persist)
   at PX.Data.PXSave`1.d__2.MoveNext()
   at PX.Data.PXAction`1.d__30.MoveNext()
   at PX.Data.PXAction`1.d__30.MoveNext()
   at PX.Web.UI.PXBaseDataSource.tryExecutePendingCommand(String viewName, String[] sortcolumns, Boolean[] descendings, Object[] searches, Object[] parameters, PXFilterRow[] filters, DataSourceSelectArguments arguments, Boolean& closeWindowRequired, Int32& adapterStartRow, Int32& adapterTotalRows)
   at PX.Web.UI.PXBaseDataSource.ExecuteSelect(String viewName, DataSourceSelectArguments arguments, PXDSSelectArguments pxarguments
halfer
  • 19,824
  • 17
  • 99
  • 186
John
  • 763
  • 3
  • 11
  • Is it the PXUIFieldAttribute.SetEnabled(cache, rows, true); that is giving issues or piece of code we don't see? – JvD Mar 18 '21 at 05:42
  • Hi JvD, you are correct, this line of code is throwing the error, we also made some header fields editable those are working without issues, but as i said, when we made line level fields editable we are getting this issue. – John Mar 18 '21 at 09:35

1 Answers1

0

I think your best bet is to add that field to your screen and check what the value is: enter image description here

Then can also try to suppress the error like this:

namespace PX.Objects.SO
{
  public class SOInvoiceEntry_Extension : PXGraphExtension<SOInvoiceEntry>
  {
    #region Event Handlers

    protected void ARTran_ProjectID_FieldVerifying(PXCache cache, PXFieldVerifyingEventArgs e)
    {
      
      e.Cancel = true;
      
    }

    #endregion
  }
}
JvD
  • 473
  • 3
  • 18