Solved

Unbound field being used in two screens causing error in one screen

  • 12 August 2021
  • 2 replies
  • 310 views

Userlevel 6
Badge +3

I have created two unbound fields on the Create Transfer Orders screen (SO509000). This screen defaults to showing the Purchasing QTY and UOM.  The customer wants to also see the “Sales” QTY and UOM on the screen.

The screen works as I desired.  Below, you can see that 0.02 of a BOX UOM is what the Prepare Replenishment screen calculated when I set it to transfer 5 units.  For that item, I set the BOX to be 250 units in a box.  So far so good.

The unbound fields are created like this: NOTE: even though there is a “Usr” in the field, they are not actually in any table.  I could create them without Usr prefix, but it doesn’t really matter here.

    public class INItemPlanExt : PXCacheExtension<PX.Objects.IN.INItemPlan>
    {
        #region UsrTransferredUOM
        [PXString(6)]
        [PXUIField(DisplayName = "Transferred UOM")]
        [PXDBCalced(typeof(INUnit.toUnit), typeof(string))]
        public virtual string UsrTransferredUOM { get; set; }
        public abstract class usrTransferredUOM : PX.Data.BQL.BqlString.Field<usrTransferredUOM> { }
        #endregion

        #region UsrTransferredQTY
        [PXDBCalced(typeof(INItemPlan.planQty), typeof(decimal))]
        [PXDecimal]
        [PXUIField(DisplayName = "Transferred QTY")]

        public virtual Decimal? UsrTransferredQTY { get; set; }
        public abstract class usrTransferredQTY : PX.Data.BQL.BqlDecimal.Field<usrTransferredQTY> { }
        #endregion
    }
 

PROBLEM:

Note that the INItemPlan table is also used in the Prepare Replenishment screen (IN508000).  When you attempt to process a replenishment item, an error is thrown because in that screen, the [PXDBCalced(typeof(INUnit.toUnit), typeof(string))] references a table that is not used on that screen.  Even though it is an unbound field, the screen tries to populate the unbound field with a field from a table not on that screen.

 

If you try to add any custom fields to the Create Transfer Orders screen, it adds them to the INItemPlan table.  In order to show those fields on the Create Transfer Orders screen, I have no choice but to add them to the INItemPlanExt.

I thought about removing the [PXDBCalced(typeof(INUnit.toUnit), typeof(string))] from the UsrTransferredQTY field and set the value in the RowSelected event for the Create Transfer Orders screen when the items are displayed on the Create Transfer Orders screen, but I cannot find a way to reference the ITItemPlanExt unbound fields in that event.  In the code below, the actual RowSelected event for the grid is on the SOFixedDemand cache.  There is no way to get a reference to the UDF’s as they are not in that cache.

        protected void SOFixedDemand_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {

            SOFixedDemand row = (SOFixedDemand)e.Row;

            INUnit unit = SelectFrom<INUnit>.Where<INUnit.inventoryID.IsEqual<@P.AsInt>>
                                    .View.Select(Base, row.InventoryID);

THIS LINE FAILS

            INItemPlanExt itemExt = PXCache<SOFixedDemand>.GetExtension<INItemPlanExt>(row);

        }
 

I do NOT WANT to set the value in the RowSelected handler.  It works just fine as the code is currently as the ONLY thing I am trying to do is display the two unbound fields.  Is there a way to work around the [PXDBCalced(typeof(INUnit.toUnit), typeof(string))] so that it only fires “conditionally” when the Prepare Replenishment screen fires?

Thanks,

Joe

icon

Best answer by gprice27 13 August 2021, 16:39

View original

2 replies

Userlevel 3
Badge

Hi Joe

 

Your DBCalc field works in the first screen (SO509000) because the view for this processing screen in a PXProjection - SOFixedDemand (inherited from INItemPlan) and includes a join to INUnit

[PXProjection(typeof(Select2<INItemPlan, InnerJoin<INPlanType, On<INPlanType.planType, Equal<INItemPlan.planType>, And<INPlanType.isFixed, Equal<boolTrue>, And<INPlanType.isDemand, Equal<boolTrue>>>>, InnerJoin<InventoryItem, On<InventoryItem.inventoryID, Equal<INItemPlan.inventoryID>>, InnerJoin<INUnit, On<INUnit.inventoryID, Equal<InventoryItem.inventoryID>, And<INUnit.fromUnit, Equal<InventoryItem.purchaseUnit>, And<INUnit.toUnit, Equal<InventoryItem.baseUnit>>>>>>>, Where<INItemPlan.supplyPlanID, IsNull, And<INItemPlan.hold, Equal<boolFalse>>>>))]*/ [SOCreateProjectionAttribute]

[Serializable] public partial class SOFixedDemand : INItemPlan

 

Screen IN508000, for the details grid, it uses the view ‘records’ of type INReplenishmentItem which inherits from INItemSIte

It is not a projection with direct joins to either InItemPlan or INUnit.

INItemPlan is used in the process delegate (ReplenishmentCreateProc) - so hence your error when INItemPlan is queried without a join to INUnit… 

 

If you do not want to use the Row selected event to get the value - perhaps consider using PXDBScalar instead of PXDBCalc..  With PxDBScalar you basically do a ‘lookup’ of the value you need, based on a field that exists on the DAC..

Hope this helps.

 

regards

Grahame

 

 

Userlevel 6
Badge +3

Who’s my hero???   Grahame is!!

Worked great.  Thank you!  I’ve never used that one before.  

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