Skip to main content
Solved

Issue with PXFormula field within PXProjection

  • February 18, 2025
  • 4 replies
  • 49 views

Forum|alt.badge.img

Ive created a PXProjection DAC and Im just trying to multiple a field by a constant (for now).

 

The PXFormula field of DfltCompQtyCalc keeps returning null no matter what I try? It works when I remove the Multiply<> operator. Also if I just define the PXFormula<index1>.. I get a list of 2’s so the constant is fine also? Why cant I multiply the two!!

 

 

using System;
using PX.Data;
using PX.Data.BQL;
using PX.Data.BQL.Fluent;
using PX.Data.ReferentialIntegrity.Attributes;
using PX.Data.WorkflowAPI;
using PX.Objects.CM;
using PX.Objects.Common.Attributes;
using PX.Objects.CS;
using PX.Objects.GL;
using PX.Objects.IN;
using PX.Objects.PO;
using PX.Objects.SO;

namespace AutoKitAssembly
{


    [Serializable]
    [PXCacheName("KitAssy_Sub2")]


    [PXProjection(typeof(Select2<INKitSpecStkDet,
                         InnerJoin<KitAssy_Sub1,On<INKitSpecStkDet.kitInventoryID,Equal<KitAssy_Sub1.kitInventoryID>,And<INKitSpecStkDet.revisionID,Equal<KitAssy_Sub1.revisionID>>>>
                         >))]

    public partial class KitAssy_Sub2: PXBqlTable, IBqlTable
    {
        #region KitInventoryID
        public abstract class kitInventoryID : PX.Data.BQL.BqlInt.Field<kitInventoryID> { }
        [StockItem(IsKey = true, BqlField = typeof(INKitSpecStkDet.kitInventoryID), Enabled = true)]
        public virtual Int32? KitInventoryID { get; set; }
        #endregion


        #region RevisionID
        public abstract class revisionID : PX.Data.BQL.BqlString.Field<revisionID> { }
        [PXDBString(100, IsUnicode = true, IsKey = true, InputMask = "", BqlField = typeof(INKitSpecStkDet.revisionID))]
        public virtual String RevisionID { get; set; }
        #endregion

        #region KitInventoryID
        public abstract class compInventoryID : PX.Data.BQL.BqlInt.Field<compInventoryID> { }
        [StockItem(IsKey = true, BqlField = typeof(INKitSpecStkDet.compInventoryID), Enabled = true)]
        public virtual Int32? CompInventoryID { get; set; }
        #endregion

        #region DfltCompQty
        public abstract class dfltCompQty : PX.Data.BQL.BqlDecimal.Field<dfltCompQty> { }
        [PXDBDecimal(IsKey = true, BqlField = typeof(INKitSpecStkDet.dfltCompQty))]
        public virtual Decimal? DfltCompQty { get; set; }
        #endregion

        private class index1 : Constant<decimal>
        {
        public index1() : base(2m) { }
        }

         #region DfltCompQtyCalc
        public abstract class dfltCompQtyCalc: PX.Data.BQL.BqlDecimal.Field<dfltCompQtyCalc> { }
        [PXDecimal()]
        [PXFormula( typeof(Mult<INKitSpecStkDet.dfltCompQty,index1>), null)]
        public virtual Decimal? DfltCompQtyCalc { get; set; }
        #endregion

          #region DfltCompQtyCalc2
        public abstract class dfltCompQtyCalc2: PX.Data.BQL.BqlDecimal.Field<dfltCompQtyCalc2> { }
        [PXDecimal()]
        [PXFormula( typeof(INKitSpecStkDet.dfltCompQty), null)]
        public virtual Decimal? DfltCompQtyCalc2 { get; set; }
        #endregion


    }

}

 

Best answer by saifalisabri

My response was crafted with AI assistance, tailored to provide detailed and actionable guidance for your query.
The issue with PXFormula in a PXProjection may be due to:

  1. Formula Execution Scope – Ensure the formula references fields correctly within the projection, as PXProjection does not always resolve formulas like standard DACs.
  2. BQL Compatibility – Use aggregated BQL functions (e.g., Aggregate<>) where necessary.
  3. Cache Refresh – If the field is not updating, try calling Base.Caches[typeof(YourDAC)].Clear(); in the graph.
  4. Alternative Approach – Compute the field in a PXDBCalced attribute instead of PXFormula.
View original
Did this topic help you find an answer to your question?

4 replies

Forum|alt.badge.img+8
  • Captain II
  • 368 replies
  • February 18, 2025

Hi ​@Dantheman88988 

 

I believe you want Mult<> rather than Multiply<>.

 

Aleks


davidnavasardyan
Jr Varsity I
Forum|alt.badge.img+2

Hey ​@Dantheman88988 

Looks like you're running into an issue with PXFormula inside a PXProjection. The problem is likely because formulas don't always behave as expected in projections, especially when trying to do calculations like multiplication.

A simple fix is to reference dfltCompQty directly in the formula instead of pulling it from INKitSpecStkDet:

 

[PXDecimal()]
[PXFormula(typeof(Mult<dfltCompQty, index1>), null)]
public virtual Decimal? DfltCompQtyCalc { get; set; }

 


saifalisabri
Jr Varsity II
Forum|alt.badge.img
  • Jr Varsity II
  • 44 replies
  • Answer
  • February 22, 2025

My response was crafted with AI assistance, tailored to provide detailed and actionable guidance for your query.
The issue with PXFormula in a PXProjection may be due to:

  1. Formula Execution Scope – Ensure the formula references fields correctly within the projection, as PXProjection does not always resolve formulas like standard DACs.
  2. BQL Compatibility – Use aggregated BQL functions (e.g., Aggregate<>) where necessary.
  3. Cache Refresh – If the field is not updating, try calling Base.Caches[typeof(YourDAC)].Clear(); in the graph.
  4. Alternative Approach – Compute the field in a PXDBCalced attribute instead of PXFormula.

Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 31 replies
  • February 26, 2025

Yes correct ​@saifalisabri PXDBCalced works as expected, why PXFormula doesnt work will remain a mystery I suppose.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings