Deborah Min
Deborah Min

Reputation: 1

Acumatica-Custom Data field carry from one table to another

I added custom fields on SOOrderDiscountDetail table and ARInvoiceDiscountDetail table. When I create invoice from the sales order screen, I want the value in my custom field in SOORderDiscountDetailExt to ARInvoiceDiscountDetailExt. I have currently override the InvoiceOrder method of SOInvoiceEntry Graph. And here is the code that I have tried. The problem is when I run with debug mode, the data is carried but it is not carried on the actual screen. Am I missing something?

my DAC Extensions

public class SOOrderDiscountDetailExt : PXCacheExtension<PX.Objects.SO.SOOrderDiscountDetail> {

    #region UsrEXTDiscount
    [PXDBString]
    [PXUIField(DisplayName="EXTDiscount")]
    public virtual string UsrEXTDiscount { get; set; }
    public abstract class usrEXTDiscount : PX.Data.BQL.BqlString.Field<usrEXTDiscount> { }
    #endregion
}

public class SOOrderDiscountDetailExt : PXCacheExtension<PX.Objects.SO.SOOrderDiscountDetail> {

    #region UsrEXTDiscount
    [PXDBString]
    [PXUIField(DisplayName="EXTDiscount")]
    public virtual string UsrEXTDiscount { get; set; }
    public abstract class usrEXTDiscount : PX.Data.BQL.BqlString.Field<usrEXTDiscount> { }
    #endregion
}

And this is my Graph Extension

public class SOInvoiceEntry_Extension : PXGraphExtension {

    public delegate void InvoiceOrderDelegate(DateTime invoiceDate, PXResult<SOOrderShipment, SOOrder, CurrencyInfo, SOAddress, SOContact> order, PXResultset<SOShipLine, SOLine> details, Customer customer, InvoiceList list, PXQuickProcess.ActionFlow quickProcessFlow, bool groupByDefaultOperation);
    [PXOverride]
    public void InvoiceOrder(DateTime invoiceDate, PXResult<SOOrderShipment, SOOrder, CurrencyInfo, SOAddress, SOContact> order, PXResultset<SOShipLine, SOLine> details, Customer customer, InvoiceList list, PXQuickProcess.ActionFlow quickProcessFlow, bool groupByDefaultOperation,InvoiceOrderDelegate basemethod)
    {
        basemethod?.Invoke(invoiceDate, order, details, customer, list, quickProcessFlow, groupByDefaultOperation);

        PXCache cache = Base.Caches[typeof(SOLine)];
        PXSelectBase<SOLine>transactions=new PXSelect<SOLine, Where<SOLine.orderType, Equal<Current<SOOrder.orderType>>, And<SOLine.orderNbr, Equal<Current<SOOrder.orderNbr>>>>>(Base);
        PXSelectBase<SOOrderDiscountDetail> discountdetail = new PXSelect<SOOrderDiscountDetail,Where<SOOrderDiscountDetail.orderType, Equal<Current<SOOrder.orderType>>,And<SOOrderDiscountDetail.orderNbr, Equal<Current<SOOrder.orderNbr>>>>>(Base);
        TwoWayLookup<SOOrderDiscountDetail, SOLine> discountCodesWithApplicableSOLines = DiscountEngineProvider.GetEngineFor<SOLine, SOOrderDiscountDetail>().GetListOfLinksBetweenDiscountsAndDocumentLines(cache, transactions, discountdetail);
        TwoWayLookup<ARInvoiceDiscountDetail, ARTran> discountCodesWithApplicableARLines = new TwoWayLookup<ARInvoiceDiscountDetail, ARTran>(leftComparer: new ARInvoiceDiscountDetail.ARInvoiceDiscountDetailComparer());
        ARInvoiceDiscountDetail arinvoice = new ARInvoiceDiscountDetail();
        foreach (SOOrderDiscountDetail docGroupDisc in discountCodesWithApplicableSOLines.LeftValues)
        {
            ARInvoice newdoc =new ARInvoice();
            ARInvoiceDiscountDetail dd = new ARInvoiceDiscountDetail();
            SOOrderDiscountDetailExt sodiscountdetailExt = docGroupDisc.GetExtension<SOOrderDiscountDetailExt>();

            ARInvoiceDiscountDetailExt ardiscountdetailExt = PXCache<ARInvoiceDiscountDetail>.GetExtension<ARInvoiceDiscountDetailExt>(dd);

            PXCache<ARInvoiceDiscountDetail>.GetExtension<ARInvoiceDiscountDetailExt>(dd).UsrEXTDiscount = docGroupDisc.GetExtension<SOOrderDiscountDetailExt>().UsrEXTDiscount;
            Base.Caches[typeof(ARInvoiceDiscountDetail)].SetValueExt<ARInvoiceDiscountDetailExt.usrEXTDiscount>(ardiscountdetailExt, sodiscountdetailExt.UsrEXTDiscount);
            Base.Caches[typeof(ARInvoiceDiscountDetail)].Update(ardiscountdetailExt);

}

Upvotes: 0

Views: 355

Answers (1)

Kyle Vanderstoep
Kyle Vanderstoep

Reputation: 771

Deborah,

Call Base.Actions.PressSave() at the very bottom of the InvoiceOrderDelegate, it is getting lost between when the record is generated and when it is shown.

Upvotes: 0

Related Questions