How To Use Pxdbscalar With Pxprojection


Hello everybody,

today I want to write a few words about how to use PXDBscalar in connection with PXProjection and is it possible at all.

First of all want to say that it's defientely a possiblity. Take a look on this sample of implementation:

	InnerJoin<FABookOn<FABook.bookIDEqual<FABookBalance.bookID>>>>>), new Type[] { typeof(FABookBalance) })]
public partial class FABookBalance : PX.Data.IBqlTable

as you see, above goes projection of FABookBalance, FABookHistory, FABook. Three DAC classes. And then take a look on how it can be used in PXDBScalar:

public abstract class classID : PX.Data.BQL.BqlInt.Field<classID> { }
protected Int32? _ClassID;
[PXDefault(typeof(Search<FixedAsset.classIDWhere<FixedAsset.assetIDEqual<Current<FABookBalance.assetID>>>>))] [PXSelector(typeof(Search<FixedAsset.assetID>), SubstituteKey = typeof(FixedAsset.assetCD), CacheGlobal = true, DescriptionField = typeof(FixedAsset.description))] [PXUIField(DisplayName = "Asset Class", Enabled = false)] public virtual Int32? ClassID { get { return this._ClassID; } set { this._ClassID = value; } }

As you see from code sample, it has calculation from totaly another class even: FixedAsset. Pretty cool? 

Take a look on another example:

                            Or<FSSODet.lineTypeEqual<ListField_LineType_ALL.Instruction_Part>>>>>), Persistent = true)]
    public class FSSODetPart : FSSODet

and take notice of PXDBScalar usage inside of that class:

        public new abstract class planType : PX.Data.BQL.BqlString.Field<planType> { }

        [PXDefault(typeof(Search<INPlanType.planTypeWhere<INPlanType.inclQtyFSSrvOrdBookedEqual<True>>>), PersistingCheck = PXPersistingCheck.Nothing)]         [PXString(SOOrderTypeOperation.orderPlanType.Length, IsFixed = true)]         public override String PlanType         {             get             {                 return this._PlanType;             }             set             {                 this._PlanType = value;             }         }

As you can see from he code sample, PXProjection is built on FSSODet table only, but for calculation of it's value it uses INPlantype table. 


If to summarize, you can use PXProjection with PXDBScalar. The only word of warning I have is during web api calls, you may potentially face cases when Acumatica team decided to make optimization, and PXDBSCalar can be skipped. There are ways of dealing with skipping of it also with help of attribute PXDependsOnField.

Comments are closed