Solved

Projected DAC Shows Wrong Values For Custom Fields

  • 29 October 2023
  • 4 replies
  • 47 views

Userlevel 4
Badge +1

Hi All,

 

I have created a projected DAC as follows. 

  [Serializable]
  [PXCacheName("ProjectedSOLines")]
    [PXProjection(
         typeof(Select2<SOLine,
        InnerJoin<SOOrder, On<SOLine.orderType, Equal<SOOrder.orderType>,
            And<SOLine.orderNbr, Equal<SOOrder.orderNbr>>>>>), Persistent = true)]

 public partial class ProjectedSOLines : IBqlTable
  {
        public abstract class orderNbr : PX.Data.BQL.BqlString.Field<orderNbr> { }
        [PXDBString(15, IsKey = true, IsUnicode = true, InputMask = ">CCCCCCCCCCCCCCC", BqlField = typeof(SOOrder.orderNbr))]
        [PXSelector(typeof(SOOrder.orderNbr))]
        [PXUIField(DisplayName = "Order Nbr.", Visibility = PXUIVisibility.SelectorVisible, Enabled = false)]
        //Other attributes like PXSelector
        public virtual String OrderNbr { get; set; }


    #region Status
    public abstract class status : PX.Data.BQL.BqlString.Field<status> { }
    [PXDBString(1, IsFixed = true, BqlField = typeof(SOOrder.status))]
    [PXUIField(DisplayName = "Status", Visibility = PXUIVisibility.SelectorVisible, Enabled = false)]
    [SOOrderStatus.List]
    [PXDefault]
    public virtual String Status { get; set; }
    #endregion

    #region Remark
    public abstract class remark : PX.Data.BQL.BqlString.Field<remark> { }
    [PXDBString(BqlField = typeof(SOLineExt.usrRemark))]
    [PXUIField(DisplayName = "Remark")]
    public virtual String Remark { get; set; }

    #endregion
}

 

But for Some records Remark field shows wrong values as follows in the Grid which I created using Projected DAC. 

Remark Values Showing In Projected DAC

 

Actual SOLine values for remark field as follows.

Actual Remark Values

What did I do wrong here? Any help would be much appreciated.

 

Thanks.

 

icon

Best answer by vardan22 30 October 2023, 06:26

View original

4 replies

Userlevel 4
Badge +1

You need to add all SOLine key fields in you DAC for projection and mark all of it as IsKey = true, that will allow you to get records correctly

Userlevel 4
Badge +1

@vardan22  Do I need to do that for each and every DAC if I have multiple table joins in the Projection?

Userlevel 4
Badge +1

@vardan22  Do I need to do that for each and every DAC if I have multiple table joins in the Projection?

Like any other DAC, you must define key fields to set uniqueness conditions for its records by setting the IsKey = true.
In your code you are trying to get rows from the SOLine table, so this means you must declare OrderType, OrderNbr and LineNbr as key fields to be able to get the correct data.
In other examples, you must decide what data you need and then prepare key fields depending on the specific requirements.

Userlevel 4
Badge +1

@vardan22 Thanks for the response!
Imagine, I have joined InventoryItem and AMProdItem tables with SOLine in the Projected DAC. Then what are the fields that I need to set as Keys(IsKey=true).?  

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