Solved

How to Update customized fields from SubContract Line to Bills and Adjustment Line while creating AP Bills from SubContract

  • 28 November 2021
  • 4 replies
  • 130 views

Userlevel 4
Badge

2

Hi All,

I have  2 customized fields in subcontract Lines. while creating AP bills from subcontract I want to carry forward this field values to another custom field in Bills and Adjustment Line. I tried to achieve this through “CreateAPInvoice” override method in Subcontract ,  but i’m not sure how to execute this correctly below are my incomplete lines of code. Could anyone please help me on this.

 

 

Regards,

Ramya

icon

Best answer by Naveen Boga 29 November 2021, 00:06

View original

4 replies

Userlevel 7
Badge +11

Hi @ramya15 

Please find the ways to deriving Values of Custom Fields 

Ways:
1. Override methods that are used to create child record
2. Use events
3. Use the PXDefault attribute 

Example:

Use of Methods

[PXOverride]
public virtual ARTran CreateTranFromShipLine(...)
{
    ARTran tran = baseMethod(newdoc, ordertype, operation, orderline, ref shipline);
 
    SOLine line = PXSelect<SOLine,
        Where<SOLine.orderType, Equal<Required<SOLine.orderType>>,
        And<SOLine.orderNbr, Equal<Required<SOLine.orderNbr>>,
        And<SOLine.lineNbr, Equal<Required<SOLine.lineNbr>>>>>>
        .Select(Base, orderline.OrderType, orderline.OrderNbr, orderline.LineNbr);
 
    var value = Base.Caches[typeof(SOLine)].GetValue<SOLineExt.isDeductible>(line);
    Base.Caches[typeof(ARTran)].SetValue<ARTranExt.isDeductible>(tran, value);
    return tran;
}


Use of Events

public virtual void ARTran_IsDeductible_FieldDefaulting(...)
{
    ARTran tran = (ARTran)e.Row;
 
    SOLine line = PXSelect<SOLine,
        Where<SOLine.orderType, Equal<Required<SOLine.orderType>>,
        And<SOLine.orderNbr, Equal<Required<SOLine.orderNbr>>,
        And<SOLine.lineNbr, Equal<Required<SOLine.lineNbr>>>>>>
            .Select(Base, tran.SOOrderType, tran.SOOrderNbr, tran.SOOrderLineNbr);
            
    e.NewValue = Base.Caches[typeof(SOLine)].GetValue<SOLineExt.isDeductible>(line);
}

Use of PXDefaultAttribute

public sealed class ARTranExtAttributes : PXCacheExtension<ARTran>
{
    #region IsDeductible
    public abstract class isDeductible : IBqlField { }
    [PXDBBool]
    [PXDefault(typeof(Search<SOLineExt.isDeductible,
            Where<SOLine.orderType, Equal<ARTran.sOOrderType>,
            And<SOLine.orderNbr, Equal<ARTran.sOOrderNbr>,
            And<SOLine.lineNbr, Equal<ARTran.sOOrderLineNbr>>>>>),
    PersistingCheck = PXPersistingCheck.Nothing)]
    [PXUIField(DisplayName = "Deductible", Visible = true)]
    public bool? IsDeductible
    {
        get;
        set;
    }
 

Hope this help you.

Userlevel 7
Badge +17

Hi @ramya15   We can achieve your requirement using [PXDefault()] attribute. 

Below code I have verified, with join conditions and it is fetching the data properly from Subcontracts screen to Bills and Adjustments screen.

 

Please find the code samples below, which you are looking for. Hope this helps! 

Let me know if this is working for you as well.

 public sealed class ARTranExt : PXCacheExtension<ARTran>
    {
        #region UsrLADperDay

        [PXDBDecimal()]
        [PXDefault(typeof(Search<POLineExt.usrLADperDay,
                Where<POLine.orderType, Equal<Current<APTran.pOOrderType>>,
                And<POLine.orderNbr, Equal<Current<APTran.pONbr>>,
                And<POLine.lineNbr, Equal<Current<APTran.pOLineNbr>>>>>>),
        PersistingCheck = PXPersistingCheck.Nothing)]
        [PXUIField(DisplayName = "LAD Per Day")]
        public virtual decimal? UsrLADperDay { get; set; }
        public abstract class usrLADperDay : PX.Data.BQL.BqlDecimal.Field<usrLADperDay> { }


        #region UsrLADAmount

        [PXDBDecimal()]
        [PXDefault(typeof(Search<POLineExt.usrLADAmount,
                Where<POLine.orderType, Equal<Current<APTran.pOOrderType>>,
                And<POLine.orderNbr, Equal<Current<APTran.pONbr>>,
                And<POLine.lineNbr, Equal<Current<APTran.pOLineNbr>>>>>>),
        PersistingCheck = PXPersistingCheck.Nothing)]
        [PXUIField(DisplayName = "LAD Amount")]
        public virtual decimal? UsrLADAmount { get; set; }
        public abstract class usrLADAmount : PX.Data.BQL.BqlDecimal.Field<usrLADAmount> { }

    }

 

Userlevel 4
Badge

Thanks @Naveen B and @jinin 

Both logics are working. Thank you so much.

Userlevel 7
Badge +17

@ramya15 Great, Thanks for sharing the update.

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved