Solved

How to pass in a parameter to a PXSelectBase

  • 19 October 2023
  • 3 replies
  • 68 views

Userlevel 6
Badge +3

I am overriding the Process Shipments screen by adding a custom filter.  

For testing, I created a “Five” class and if I put Five instead of @P.AsInt, it works great. 

In the PXSelectBase command, I am able to put @P.AsInt in the statement, but I don’t know how to pass in my value.  How do I pass in the value to the @P?

This is the “Five” class which returns an integer 5.

    public class Five : PX.Data.BQL.BqlInt.Constant<Five>
    {
        public Five() : base(ICSConstants.Five)
        {
        }
    }

This is the command I am overriding

                                    cmd = new
                                        SelectFrom<SOShipment>.
                                        InnerJoin<INSite>.On<SOShipment.FK.Site>.
                                        InnerJoin<Customer>.On<SOShipment.customerID.IsEqual<Customer.bAccountID>>.SingleTableOnly.
                                        LeftJoin<Carrier>.On<SOShipment.FK.Carrier>.
                                        Where<
                                            SOShipment.confirmed.IsEqual<True>.
                                            And<Match<Customer, AccessInfo.userName.FromCurrent>>.
                                            And<Match<INSite, AccessInfo.userName.FromCurrent>>.
                                            And<Exists<
                                                SelectFrom<SOOrderShipment>.
                                                Where<
                                                    SOOrderShipment.shipmentNbr.IsEqual<SOShipment.shipmentNbr>.
                                                    And<SOOrderShipment.shipmentType.IsEqual<SOShipment.shipmentType>>.
                                                    And<SOOrderShipment.invoiceNbr.IsNull>.
                                                    And<SOOrderShipment.createARDoc.IsEqual<True>>.
                                                    And<SOOrderShipment.shipmentQty.IsLess<@P.AsInt>>>>>>.
                                        View(Base);

If I try to use View.Select(Base, 5) it won’t compile.

icon

Best answer by Naveen Boga 20 October 2023, 05:53

View original

3 replies

Userlevel 7
Badge +17

@Joe Schmucker  Have you tried like below?

 

  var cmd = new
SelectFrom<SOShipment>.
InnerJoin<INSite>.On<SOShipment.FK.Site>.
InnerJoin<Customer>.On<SOShipment.customerID.IsEqual<Customer.bAccountID>>.SingleTableOnly.
LeftJoin<Carrier>.On<SOShipment.FK.Carrier>.
Where<
SOShipment.confirmed.IsEqual<True>.
And<Match<Customer, AccessInfo.userName.FromCurrent>>.
And<Match<INSite, AccessInfo.userName.FromCurrent>>.
And<Exists<SelectFrom<SOOrderShipment>.
Where<
SOOrderShipment.shipmentNbr.IsEqual<SOShipment.shipmentNbr>.
And<SOOrderShipment.shipmentType.IsEqual<SOShipment.shipmentType>>.
And<SOOrderShipment.invoiceNbr.IsNull>.
And<SOOrderShipment.createARDoc.IsEqual<True>>.
And<SOOrderShipment.shipmentQty.IsEqual<@P.AsInt>>>>>>.View(Base);


SOShipment result = cmd.Select(5);

 

Userlevel 6
Badge +3

Hi @Naveen Boga !

Unfortunately, the thing I am overriding is just the part that prepares the command.  It gets executed elsewhere.

 

		public virtual PXSelectBase GetShipmentsSelectCommand(SOShipmentFilter filter, GetShipmentsSelectCommandDelegate baseMethod)
{
PXSelectBase cmd;

string customFilter = string.Empty;

switch (filter.Action)
{
case CreateInvoice:
{
SOShipmentFilterExt ext = PXCache<SOShipmentFilter>.GetExtension<SOShipmentFilterExt>(filter);

ICSProcessShipmentsFilters test = stuff.Current;

if (ext.UsrBatchType != null)
{
customFilter = ext.UsrBatchType.Trim();
}

switch (customFilter)
{
case ICSConstants.QtyLessThan5:
{
cmd = new
SelectFrom<SOShipment>.
InnerJoin<INSite>.On<SOShipment.FK.Site>.
InnerJoin<Customer>.On<SOShipment.customerID.IsEqual<Customer.bAccountID>>.SingleTableOnly.
LeftJoin<Carrier>.On<SOShipment.FK.Carrier>.
Where<
SOShipment.confirmed.IsEqual<True>.
And<Match<Customer, AccessInfo.userName.FromCurrent>>.
And<Match<INSite, AccessInfo.userName.FromCurrent>>.
And<Exists<
SelectFrom<SOOrderShipment>.
Where<
SOOrderShipment.shipmentNbr.IsEqual<SOShipment.shipmentNbr>.
And<SOOrderShipment.shipmentType.IsEqual<SOShipment.shipmentType>>.
And<SOOrderShipment.invoiceNbr.IsNull>.
And<SOOrderShipment.createARDoc.IsEqual<True>>.
And<SOOrderShipment.shipmentQty.IsLess<Five>>>>>>.
View(Base);

break;
}
//more stuff here but removed for brevity

return cmd;
}

Maybe I have to override another one where that command gets executed.  The first override would be to prepare the command and the second override would be to provide the actual value. 

I’ll try to find where in the graph the cmd gets executed and see if it can be overridden.

Userlevel 6
Badge +3

@Naveen Boga after looking a little deeper, I don’t think I need to be overriding the code that creates the cmd.  I need to override the method that applies the filters to that cmd.

Thanks for the insight.  FYI, your first answer is correct as it does answer my original question.  This answer WILL help me in the future and it explains how that parameter gets populated in the select command.

THANK YOU NAVEEN.

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