Skip to main content
Solved

Can you reference other DACs in a PXFilteredProcessingJoin or is it only for display?

  • 5 September 2024
  • 5 replies
  • 68 views

Forum|alt.badge.img

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();
       }

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

           [PXString(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
       }

       [Serializable]
       [PXCacheName("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 { }
       }

       [Serializable]
       [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 { }
       }

       [PXCacheName("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 { }
       }

 

Best answer by taras

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)

View original
Did this topic help you find an answer to your question?

5 replies

Forum|alt.badge.img+7
  • Captain II
  • 295 replies
  • September 6, 2024

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


Forum|alt.badge.img+1
  • Jr Varsity I
  • 21 replies
  • Answer
  • September 6, 2024

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)


Forum|alt.badge.img+7
  • Captain II
  • 295 replies
  • September 6, 2024

Thanks for that @taras!


darylbowman
Captain II
Forum|alt.badge.img+13
taras wrote:

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.


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 21 replies
  • September 9, 2024

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings