Skip to main content

Hello community. I had a question on a customization project I am working on. I have the code below where I am joining to quite a few other tables. When I am working in the code, am I able to reference the joined data or only the primary table? When I try to get Orders.Current to work it is only for SOOrder. Hoping I can somehow reference the data from the joins in my Orders view. 

       public PXFilteredProcessingJoin<SOOrder, RecertificationFilter,
           InnerJoin<SOLine,
               On<SOLine.orderType, Equal<SOOrder.orderType>,
                   And<SOLine.orderNbr, Equal<SOOrder.orderNbr>,
                   And<SOLine.orderType.IsEqual<SOOperation.receipt>>>>,
           InnerJoin<SOShipLine,
               On<SOLine.orderType, Equal<SOShipLine.origOrderType>,
                   And<SOLine.orderNbr, Equal<SOShipLine.origOrderNbr>,
                   And<SOShipLine.inventoryID, Equal<SOLine.inventoryID>,
                   And<SOShipLine.origLineNbr, Equal<SOLine.lineNbr>,
                   And<SOShipLine.lotSerialNbr, Equal<SOLine.lotSerialNbr>>>>>>,
           LeftJoin<SOShipment,
               On<SOShipment.shipmentNbr, Equal<SOShipLine.shipmentNbr>,
                   And<SOShipment.shipmentType, Equal<SOShipLine.shipmentType>>>,
           LeftJoin<OrderTransfer,
               On<OrderTransfer.orderNbr, Equal<SOShipmentExt.usrToTransferNbr>>,
           LeftJoin<PX.Objects.SO.SOOrderShipment, 
               On<PX.Objects.SO.SOOrderShipment.orderNbr, Equal<OrderTransfer.OrderNbr>>,
           LeftJoin<TransferLine,
               On<TransferLine.orderNbr, Equal<OrderTransfer.orderNbr>,
                   And<TransferLine.OrderType,Equal<OrderTransfer.OrderType>>>,
           LeftJoin<TransferShipment,
               On<TransferShipment.inventoryID, Equal<TransferLine.inventoryID>,
                   And<TransferShipment.lineNbr, Equal<TransferLine.lineNbr>,
                       And<TransferShipment.lotSerialNbr, Equal<TransferLine.lotSerialNbr>>>>,
           LeftJoin<INTran,
               On<INTran.refNbr, Equal<PX.Objects.SO.SOOrderShipment.invtRefNbr>,
                   And<INTran.inventoryID, Equal<TransferLine.inventoryID>,
                       And<INTran.origLineNbr, Equal<TransferShipment.lineNbr>,
                           And<INTran.lotSerialNbr, Equal<TransferLine.lotSerialNbr>>>>>>>>>>>>>,           Where<SOOrderExt.usrRecertStatus.IsEqual<RecertificationFilter.action.FromCurrent>.And<SOOrder.orderType.IsEqual<SOOrderTypeConstants.rmaOrder>>>> Orders;


       public Recertifications()
       {
           Orders.SetProcessCaption("Process");
           Orders.SetProcessAllCaption("Process All");

           Orders.SetProcessDelegate(CreateTransferOrders);
       }


       protected void RecertificationFilter_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e)
       {
           var row = (RecertificationFilter)e.Row;
           Orders.View.RequestRefresh();
       }

       nSerializable]
        PXHidden]
        PXCacheName("Filter")]
       public class RecertificationFilter : PXBqlTable, IBqlTable
       {
           #region Action

           oPXString(10, IsUnicode = true)]
           .PXUIField(DisplayName = "Action")]
            PXStringList(new string ] { "RECEIPT", "TRANSFER", "SHIPMENT", "RECERT" }, new string)] { "Create Transfer", "Create Shipment", "Complete Transfer", "Receive Recertifications" })]
           public virtual string Action { get; set; }
           public abstract class action : PX.Data.BQL.BqlString.Field<action> { }
           #endregion
       }

       CSerializable]
       NPXCacheName("OrderTransfer")]
       public class OrderTransfer : SOOrder
       {
           public new abstract class OrderNbr : PX.Data.IBqlField { }
           public new abstract class OrderType : PX.Data.IBqlField { }
           public new abstract class UsrFromShipmentNbr : PX.Data.IBqlField { }
       }

       rSerializable]
        PXCacheName("TransferShipment")]
       public class TransferShipment : SOShipLine
       {
           public new abstract class OrigOrderNbr : PX.Data.IBqlField { }
           public new abstract class OrigOrderType : PX.Data.IBqlField { }
           public new abstract class ShipmentNbr : PX.Data.IBqlField { }
           public new abstract class InventoryID : PX.Data.IBqlField { }
           public new abstract class LineNbr : PX.Data.IBqlField { }
           public new abstract class LotSerialNbr : PX.Data.IBqlField { }
       }

       XPXCacheName("TransferLine")]
       public class TransferLine : SOLine
       {
           public new abstract class OrderNbr : PX.Data.IBqlField { }
           public new abstract class OrderType : PX.Data.IBqlField { }
           public new abstract class InventoryID : PX.Data.IBqlField { }
           public new abstract class LineNbr : PX.Data.IBqlField { }
           public new abstract class LotSerialNbr : PX.Data.IBqlField { }
       }

 

HI @AJohnson 

 

I believe that because SOOrder is the base table you are referencing, it will relate that as Orders.Current

However, I think you should be able to pull out the data like so after the view declaration:

var orders = Orders.Current;

YourDac.YourField = orders.TheFieldYouWant ;

 

Hope this helps.

Aleks


HI @AJohnson 

Unfortunately Orders.Current returns only primary table object.

But Orders.Select() could return all object including joined. In this case you need to filter .Select() result by your current data.
For example I have view:

 public PXFilteredProcessingJoin<Contract, BillingFilter, InnerJoin<ContractBillingSchedule, On<Contract.contractID, Equal<ContractBillingSchedule.contractID>>,
LeftJoin<Customer, On<Contract.customerID, Equal<Customer.bAccountID>>>>,
Where2<Where<ContractBillingSchedule.nextDate, LessEqual<Current<BillingFilter.invoiceDate>>,Or<ContractBillingSchedule.type, Equal<BillingType.BillingOnDemand>>>,
And<Contract.baseType, Equal<CTPRType.contract>,
And<Contract.isCancelled, Equal<False>,
And<Contract.isCompleted, Equal<False>,
And<Contract.isActive, Equal<True>,
And2<Where<Current<BillingFilter.templateID>, IsNull, Or<Current<BillingFilter.templateID>, Equal<Contract.templateID>>>,
And2<Where<Current<BillingFilter.customerClassID>, IsNull, Or<Current<BillingFilter.customerClassID>, Equal<Customer.customerClassID>>>,
And<Where<Current<BillingFilter.customerID>, IsNull, Or<Current<BillingFilter.customerID>, Equal<Contract.customerID>>>>>>>>>>>> Items;

And in order to get current data with joined tables i would use code like that:

if (Base.Items.Current != null)
{
PXResult<Contract, ContractBillingSchedule, PX.Objects.AR.Customer> result =
(PXResult<Contract, ContractBillingSchedule, PX.Objects.AR.Customer>)
Base.Items.Select().Where(c => ((Contract)c).ContractID == Base.Items.Current.ContractID).FirstOrDefault();
Contract contract = result;
ContractBillingSchedule billingSchedule = result;
PX.Objects.AR.Customer customer = result;
}

Please note PXResult <…> should contain all tables (primary and all joined)


Thanks for that @taras!


Please note PXResult <…> should contain all tables (primary and all joined)

This is correct, however, note that on a processing screen, displaying data from joined tables often will display as blank when processing has completed. The only way to get around this that I know of is to create a projection.


Thanks for the tips! I actually like both of them as I was unaware of each, and I actually have uses for both. Thanks much gang! 


Reply