Nickolas Hook
Nickolas Hook

Reputation: 804

Enable SOLine field after Order Completed

I need to enable the Salesperson ID and Commissionable fields of Sales Order Lines for Sales Orders in the Completed state.

I referenced the question here about enabling fields in the SOOrder header: How to enable CustomerOrderNbr field in Sales Order screen?

I added the two fields to the Automation Steps for the SO Complete step Automation Steps Screen

And added customization code:

public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
{
  public void SOOrderLine_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
  {
      SOOrderLine line = e.Row as SOOrderLine;
      if (line == null) return;

      PXUIFieldAttribute.SetEnabled<SOOrderLine.salesPersonID>(sender, line, true);
      PXUIFieldAttribute.SetEnabled<SOOrderLine.commissionable>(sender, line, true);
  }
}

However, the fields are still disabled. Is there something I'm missing?

Upvotes: 0

Views: 453

Answers (2)

Nickolas Hook
Nickolas Hook

Reputation: 804

To finish out the solution to this, in this case I found it was not necessary to Enable the full Sales Order Line via Automation Steps and then disable it via SOLine_RowSelect. It was, however, necessary to add the Sales Order > Order Nbr field to the automation steps (to make the document Save available after changing the Sales Order line). And strangely it was also necessary for us to give this Customization Project a higher Level than the others implementing it after other customizations that may have made changes to the same screen or objects.

Automation Steps example

public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
{
  protected void SOOrder_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
  {
      sender.AllowUpdate = true;
      Base.Transactions.Cache.AllowUpdate = true;
  }

  protected void SOLine_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
  {
      if (Base.Document.Current != null)
      {
          PXUIFieldAttribute.SetEnabled<SOLine.salesPersonID>(sender, e.Row, true);
          PXUIFieldAttribute.SetEnabled<SOLine.commissionable>(sender, e.Row, true);
      }
  }   
}

Upvotes: 0

Gabriel
Gabriel

Reputation: 3783

I have a similar requirement with one of my clients. You're on the right track with automation steps, but you need something else to enable editing. Here are the two event handlers we use:

    protected void SOOrder_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
    {
        // Make the promised on ship date field editable even after the order has been completed.
        // This code is not enough to make the feature work - automation steps need to be modified for SO Completed and SO Invoiced to ensure the
        // caches are not disabled.
        sender.AllowUpdate = true;
        Base.Transactions.Cache.AllowUpdate = true;
    }

    protected void SOLine_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
    {
        if (Base.Document.Current != null)
        {
            //Automation steps were modified to keep the transactions grid enabled for the completed status; we are manually disabling it here but leaving the promised on ship date field editable.
            if(Base.Document.Current.Status == SOOrderStatus.Completed)
                PXUIFieldAttribute.SetEnabled(sender, e.Row, false);

            PXUIFieldAttribute.SetEnabled<SOLineExt.usrPromisedShipOnDate>(sender, e.Row, true);
            PXUIFieldAttribute.SetEnabled<SOLineExt.usrLateReasonCode>(sender, e.Row, true);
        }
    }

Upvotes: 1

Related Questions