Skip to main content
Solved

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

  • Nov 28, 2021 4:36 PM UTC
  • 4 replies
  • 210 views
  • Translate All

Forum|alt.badge.img

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

Best answer by Naveen Boga

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> { }

    }

 

View original

4 replies

jinin
Pro I
Forum|alt.badge.img+12
  • Pro I
  • Nov 28, 2021 4:59 PM UTC

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.

Translate

Naveen Boga
Captain II
Forum|alt.badge.img+20
  • Captain II
  • Answer
  • Nov 28, 2021 11:06 PM UTC

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> { }

    }

 

Translate

Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • Nov 29, 2021 2:47 AM UTC

Thanks @Naveen B and @jinin 

Both logics are working. Thank you so much.

Translate

Naveen Boga
Captain II
Forum|alt.badge.img+20
  • Captain II
  • Nov 29, 2021 2:56 AM UTC

@ramya15 Great, Thanks for sharing the update.

Translate