0
votes

I have created a custom checkbox field on SO Invoice screen (SO303000) which needs to updated even after Invoice is released and payments are fully paid.

However for now I am not able to do as it is is getting disabled once invoice is Released and fully paid.

I tried to do it with Automation Steps but it is not working. I have added the custom field on Fields tab to make it enable on Closed step of SO Invoices.

Please suggest.

1

1 Answers

1
votes

To enable custom fields on the SO Invoices top-level form and Transactions grid after Invoice is released and/or closed, you should create an extension for SOInvoiceEntry and subscribe to the ARInvoice_RowSelected and ARTran_RowSelected events following the sample below:

public class SOInvoiceEntryExt : PXGraphExtension<SOInvoiceEntry>
{
    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;
    }

    public void ARInvoice_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
    {
        ARInvoice doc = e.Row as ARInvoice;
        if (doc == null) return;

        if (IsDisabled(doc))
        {
            PXUIFieldAttribute.SetEnabled<ARInvoiceExt.usrCustomTextField>(
                sender, doc, true);
            Base.Transactions.Cache.AllowUpdate = true;
        }
    }

    public void ARTran_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
    {
        var doc = Base.Document.Current;
        ARTran row = e.Row as ARTran;

        if (row != null && doc != null && IsDisabled(doc))
        {
            PXUIFieldAttribute.SetEnabled(sender, row, false);
            PXUIFieldAttribute.SetEnabled<ARTranExt.usrCustomTextField>(
                sender, row, true);
        }
    }
}

Additionally, you need to enable custom field added onto the top-level form in the Closed automation step: enter image description here

This is how the SO Invoices screen should work after you apply the changes described above:

enter image description here

enter image description here