0
votes

I've reviewed the other SO questions around enabling custom fields on AR Invoice Entry and GL Journal Transactions

However, in my case, I'm trying to enable a custom field added to the Allocations dialog of AM.30.00.00.

I made an attempt to set the batch as not read-only before trying to enable the row of the grid.

What 'thing' needs to be enabled or made not read-only to facilitate this?

namespace PX.Objects.AM
{
  public class MaterialEntry_Extension : PXGraphExtension<MaterialEntry>
  {

  protected void AMBatch_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
  {
    var row = (AMBatch)e.Row;

    if (row != null)
    {
       if (!(row.EditableBatch.GetValueOrDefault()))
       {
           cache.AllowUpdate = true;
           Base.batch.Cache.AllowUpdate = true;
           PXUIFieldAttribute.SetReadOnly(Base.batch.Cache, null, false);
       }  
    }   
  }

  protected void AMMTranSplit_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
  {
    var doc = Base.batch.Current;
    AMMTranSplit row = e.Row as AMMTranSplit;
    var editablebatch = ((AMBatch)doc).EditableBatch.GetValueOrDefault();

    if (row != null && doc != null && !(editablebatch))
    {
      PXUIFieldAttribute.SetReadOnly(cache, row, false);            
      PXUIFieldAttribute.SetEnabled(cache, row, false);
      PXUIFieldAttribute.SetEnabled<AMMTranSplitExt.usrParentSerial>(cache, row, true);
    }
  }

}}
1

1 Answers

0
votes

One must use RowSelected event of the DAC that belongs to fields whose UI need to be adjusted. Change your AMMTranSplit_RowSelected as shown below, and remove one for AMBatch as it is not needed.

        protected void AMMTranSplit_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
    {
        if (InvokeBaseHandler != null)
            InvokeBaseHandler(cache, e);
        var row = (AMMTranSplit)e.Row;

        cache.AllowUpdate = true;
        PXUIFieldAttribute.SetEnabled(cache, row, false);
        PXUIFieldAttribute.SetEnabled<AMMTranSplitExt.usrParentSerial>(cache, row);
    }

Note here how PXCache of AMMTranSplit is first set to allow update, then all fields are disabled and finally field(s) we want are enabled.