0

I have an extension for the POReceiptLineAdd Class:

public class POReceiptLineAddExt : PXCacheExtension<POReceiptLineAdd>
{
    public static bool IsActive()
    {
        return true;
    }

    #region UsrSONbr
    [PXString]
    [PXUIField(DisplayName = "Sales Order Nbr")]
    [PXUIEnabled(typeof(False))]
    public virtual string UsrSONbr { get; set; }
    public abstract class usrSONbr : BqlString.Field<usrSONbr> { }
    #endregion

    #region UsrFSNbr
    [PXString]
    [PXUIField(DisplayName = "Service Order Nbr")]
    [PXUIEnabled(typeof(False))]
    public virtual string UsrFSNbr { get; set; }
    public abstract class usrFSNbr : BqlString.Field<usrFSNbr> { }
    #endregion
}

I will fill in the values with the corresponding Sales Order or Service Order number via a separate processing form.

So, when I extend the AddPOReceiptLineExtension graph, and override the method: POReceiptLinesSelection(), I want to be able to have it pull up those values through the POReceiptLineAdd projection.

It seems that POReceiptLineAdd mainly uses POReceiptLine, so it seems like that is a good place to put the values in the database. So, I add the values usrFSNbr and UsrSONbr to POReceiptLine, but they are not I cannot retrieve them after a data read.

In other words:

                    var res = PXSelectJoin<POReceiptLineAdd,
                        InnerJoin<POReceipt,
                            On<POReceipt.receiptType, Equal<POReceiptLineAdd.receiptType>,
                                And<POReceipt.receiptNbr, Equal<POReceiptLineAdd.receiptNbr>>>>,
                        Where<POReceiptLineAdd.receiptNbr, Equal<@P.AsString>,
                            And<POReceiptLineAdd.lineNbr, Equal<@P.AsInt>>>>
                                .Select(this.Base, item.ReceiptNbr, item.ReceiptLineNbr).TopFirst;

var TST = res.GetExtension<POReceiptLineAddExt>().UsrFSNbr

Will always return a null value, even though I have put values in the SQL database.

How can I extend the projection so I can add this field to what it is retrieving?

MarkJoel60
  • 537
  • 2
  • 6
  • 24

1 Answers1

0

So... actually the answer to this was given in a Previous SO post. See: Simon ML Answer

But the question was worded differently, so I missed it.

Basically, at issue is that a Projection is not directly tied to an actual database file. (It is essentially an SQL View).

In order to get it to work correctly, and pull the values of an Extended column, you need to set up TWO extensions:

  • One for the Projection
  • One for one of the DACs the Projection uses.

In my case, for POReceiptLineAdd the most direct DAC is POReceiptLine. And it looks like this:

using PX.Data;
using PX.Data.BQL;
using PX.Data.BQL.Fluent;
using PX.Objects.AP;
using PX.Objects.PO;
using PX.Objects.PO.DAC.Projections;

//**************************************************************
// NOTE: THIS FILE CONTAINS *TWO* CLASSES USED TO EXTEND THE 
// POReceiptLine GRAPH. BOTH ARE NECESSARY.
//**************************************************************
namespace MySolution.DAC
{
    //*********************************************************************
    //This DAC extends the PROJECTION used in the POReceiptLine Graph It
    // References POReceiptLineExt, which extends the actual data access DAC
    //*********************************************************************
    public class POReceiptLineAddExt : PXCacheExtension<POReceiptLineAdd>
    {
        public static bool IsActive()
        {
            return true;
        }

        #region UsrSONbr
        [PXDBString(BqlField = typeof(POReceiptLineExt.usrSONbr))]
        [PXUIField(DisplayName = "Sales Order Nbr")]
        [PXUIEnabled(typeof(False))]
        public virtual string UsrSONbr { get; set; }
        public abstract class usrSONbr : IBqlField { }
        #endregion
        #region UsrFSNbr
        [PXDBString(BqlField = typeof(POReceiptLineExt.usrFSNbr))]
        [PXUIField(DisplayName = "Service Order Nbr")]
        [PXUIEnabled(typeof(False))]
        public virtual string UsrFSNbr { get; set; }
        public abstract class usrFSNbr : IBqlField { }
        #endregion
    }
    //*********************************************************************
    // This DAC Extends the ACTUAL database file POReceiptLine
    // NOTE: this one MUST be referenced by the Projection DAC (Above) 
    // in order for it to actually retrieve data store in the SQL data file.
    //*********************************************************************
    public class POReceiptLineExt : PXCacheExtension<POReceiptLine>
    {
        #region UsrSONbr
        [PXDBString]
        [PXUIField(DisplayName = "Sales Order Nbr")]
        public virtual string UsrSONbr { get; set; }
        public abstract class usrSONbr : BqlString.Field<usrSONbr> { }
        #endregion
        #region UsrFSNbr
        [PXDBString]
        [PXUIField(DisplayName = "Service Order Nbr")]
        public virtual string UsrFSNbr { get; set; }
        public abstract class usrFSNbr : BqlString.Field<usrFSNbr> { }
        #endregion
    }

FWIW: I am running 2021 R2.

Hope this helps someone in the future. (Probably me when I forget this and come back looking for answers...)

MarkJoel60
  • 537
  • 2
  • 6
  • 24