0
votes

I'm having an issue on the SOInvoiceEntry.cs when I create a new invoice or prepare an invoice from the SOOrderEntry->Shipment->Invoice the invoiceNbr is not being entered until the user clicks another field associated to that DAC

before pressing a field associated with the DAC before pressing a field associated with the DAC

After pressing a field with associated with the DAC enter image description here

I created a new DAC called UsrKSFSCCom

It has one isKey field among the many on the dac

[PXDBString(50, IsKey = true, IsUnicode = true, InputMask = "")]
[PXDBDefault(typeof(ARInvoice.refNbr))]
[PXUIField(DisplayName = "InvoiceNbr")]
    public string UsrInvoiceNbr { get; set; }

    public class usrInvoiceNbr : IBqlField{}

I have a ARInvoice_Rowselecting event handler set up as follows

    protected virtual void ARInvoice_RowSelecting(PXCache sender, PXRowSelectingEventArgs e, PXRowSelecting InvokeBaseHandler)
    {
        if (InvokeBaseHandler != null)
            InvokeBaseHandler(sender, e);
        ARRegister row = (ARRegister)e.Row;
        if (row == null) return;
        ARRegisterExt rowExt = PXCache<ARRegister>.GetExtension<ARRegisterExt>(row);

        ARTran invoiceCust = PXSelect<ARTran,
                                        Where<ARTran.refNbr,
                                        Equal<Required<ARTran.refNbr>>>>.Select(Base, row.RefNbr);
        if (invoiceCust == null)
            return;
        SOOrder salesOrd = PXSelect<SOOrder,
                                    Where<SOOrder.orderNbr,
                                    Equal<Required<SOOrder.orderNbr>>>>.Select(Base, invoiceCust.SOOrderNbr);

        UsrKSFSCCom fscComDef = PXSelect<UsrKSFSCCom,
                                Where<UsrKSFSCCom.usrInvoiceNbr,
                                Equal<Current<ARInvoice.refNbr>>>>.Select(Base, row.RefNbr);

        if (salesOrd == null)
            return;

        SOOrderExt saleOrdExt = PXCache<SOOrder>.GetExtension<SOOrderExt>(salesOrd);
        fscComDef.UsrInRep = saleOrdExt.UsrInRep;
        fscComDef.UsrInCom = saleOrdExt.UsrInCom;
        fscComDef.UsrManRep = saleOrdExt.UsrManRep;
        fscComDef.UsrManCom = saleOrdExt.UsrManCom;
        fscComDef.UsrMiscRep = saleOrdExt.UsrMiscRep;
        fscComDef.UsrMiscCom = saleOrdExt.UsrMiscCom;
        fscComDef.UsrOutRep = saleOrdExt.UsrOutRep;
        fscComDef.UsrOutCom = saleOrdExt.UsrOutCom;
        fscComDef.UsrIndirectCust = saleOrdExt.UsrIndirectCust;
        fscComDef.UsrOverBool = saleOrdExt.UsrOverBool;
        fscComDef.UsrOverAmt = saleOrdExt.UsrOverAmt;
        fscComDef.UsrOverageCom = saleOrdExt.UsrOverageCom;
    }

The issue is the RowSelecting Event handler works on one condition, the user must click one of the fields associated then the records appear from the row selected. Am I incorrectly defining the default value through PXDefault? Any input is appreciated, thank you.

1
I debugged the page and it seems to be grabbing all the appropriate information as expected but it's not showing up until after i select one of those fields part of the UsrKSFSCCom DAC.JB90
I'm not sure why is it working like that. But can you try this.Caches[typeof(UsrKSFSCCom )].Update(fscComDef) after you set all fields for the record?Dmitrii Naumov
I'll try that now, I'll let you know how that works out.JB90
Hmm, I had to modify the code slightly to use Base instead of this. It seems that it has no effect when the RowSelecting method is ranJB90
Update: Dimitry, the update cache did work actually. I incorrectly had a null selected record for the initial fscComDef, which was passed over in a initial rowSelecting call. I ended up creating a second new UsrKSFSCCom set it to the row.RefNbr, reassinged fscComDef.UsrInvoiceNbr = fscComDefNew.UsrInvoiceNbr and after assigning the other fields the Base.Caches updated the dac as expected. Thank you again that was the last piece i was missing! I'll write a formal answer to this question in a momentJB90

1 Answers

0
votes

Per Dmitry suggestion, adding in this Base.Caches[typeof(UsrKSFSCCom)].Update(fscComDef) at the end of the RowSelecting event handler worked.