Reputation: 94
I am trying to add a condition to a PXSelect defined on the SOShipmentEntry graph. I had read that I can just redefine the PXSelect and it would overwrite the original value with mine, but that doesn't seem to be happening.
I created the graph extension as usual, then defined the PXSelect with the extra "And" I need like this:
public PXSelectJoin<SOShipmentPlan,
InnerJoin<SOLineSplit, On<SOLineSplit.planID, Equal<SOShipmentPlan.planID>>,
InnerJoin<SOLine, On<SOLine.orderType, Equal<SOLineSplit.orderType>, And<SOLine.orderNbr, Equal<SOLineSplit.orderNbr>, And<SOLine.lineNbr, Equal<SOLineSplit.lineNbr>>>>,
InnerJoin<InventoryItem, On<InventoryItem.inventoryID, Equal<SOShipmentPlan.inventoryID>>,
LeftJoin<INLotSerClass,
On<InventoryItem.FK.LotSerClass>,
LeftJoin<INSite,
On<SOLine.FK.Site>,
LeftJoin<SOShipLine,
On<SOShipLine.origOrderType, Equal<SOLineSplit.orderType>,
And<SOShipLine.origOrderNbr, Equal<SOLineSplit.orderNbr>,
And<SOShipLine.origLineNbr, Equal<SOLineSplit.lineNbr>,
And<SOShipLine.origSplitLineNbr, Equal<SOLineSplit.splitLineNbr>,
And<SOShipLine.confirmed, Equal<boolFalse>,
And<SOShipLine.shipmentNbr, NotEqual<Current<SOShipment.shipmentNbr>>>>>>>>>>>>>>,
Where<SOShipmentPlan.siteID, Equal<Optional<SOOrderFilter.siteID>>,
And<SOShipmentPlan.planDate, LessEqual<Optional<SOOrderFilter.endDate>>,
And<SOShipmentPlan.orderType, Equal<Required<SOOrder.orderType>>,
And<SOShipmentPlan.orderNbr, Equal<Required<SOOrder.orderNbr>>,
And<SOLine.operation, Equal<Required<SOLine.operation>>,
And<SOShipLine.origOrderNbr, IsNull,
And<SOLineExt.usrShipmentHold, NotEqual<True>>
>>>>>>> ShipmentScheduleSelect;
Edit: After reviewing the code posted by Samvel, I found some additional information online and have created a delegate method below. However, when this runs, I am getting the message that the SiteID is not found, and the Site ID appears to be blank. When I step through the code, PXView seems to contain all of the parameters passed in as expected. It's almost like the parameters are being wiped out. I tried copying the parameters to a new array as well, but that also didn't work. Any ideas?
public IEnumerable shipmentScheduleSelect()
{
PXView select = new PXView(Base, true, Base.ShipmentScheduleSelect.View.BqlSelect);
select.BqlSelect.WhereAnd(typeof(Where<SOLineExt.usrShipmentHold, NotEqual<True>>));
Int32 totalrow = 0;
Int32 startrow = PXView.StartRow;
List<object> result = select.Select(PXView.Currents, PXView.Parameters,
PXView.Searches, PXView.SortColumns, PXView.Descendings,
PXView.Filters, ref startrow, PXView.MaximumRows, ref totalrow);
PXView.StartRow = 0;
return result;
}
Upvotes: 1
Views: 722
Reputation: 7706
Please see below an example of how you can add the data delegate for this specific case:
using System.Collections;
using System.Collections.Generic;
using PX.Data;
using PX.Objects.CS;
using PX.Objects.IN;
namespace PX.Objects.SO
{
public class SOShipmentEntry_Extension : PXGraphExtension<SOShipmentEntry>
{
#region Event Handlers
public IEnumerable shipmentScheduleSelect()
{
throw new PXException("TEST EXCEPTION");
/*
Replace the PXException with the override of the select as you need. Below is just an example how you can do that but make sure to provide all the parameters to the select
var cmd = new PXSelectJoin<SOShipmentPlan, InnerJoin<SOLineSplit, On<SOLineSplit.planID, Equal<SOShipmentPlan.planID>>,
InnerJoin<SOLine, On<SOLine.orderType, Equal<SOLineSplit.orderType>, And<SOLine.orderNbr, Equal<SOLineSplit.orderNbr>, And<SOLine.lineNbr, Equal<SOLineSplit.lineNbr>>>>,
InnerJoin<InventoryItem, On<InventoryItem.inventoryID, Equal<SOShipmentPlan.inventoryID>>,
LeftJoin<INLotSerClass, On<InventoryItem.FK.LotSerialClass>, LeftJoin<INSite, On<SOLine.FK.Site>,
LeftJoin<SOShipLine, On<SOShipLine.origOrderType, Equal<SOLineSplit.orderType>,
And<SOShipLine.origOrderNbr, Equal<SOLineSplit.orderNbr>,
And<SOShipLine.origLineNbr, Equal<SOLineSplit.lineNbr>,
And<SOShipLine.origSplitLineNbr, Equal<SOLineSplit.splitLineNbr>,
And<SOShipLine.confirmed, Equal<boolFalse>,
And<SOShipLine.shipmentNbr, NotEqual<Current<SOShipment.shipmentNbr>>>>>>>>>>>>>>,
Where<SOShipmentPlan.siteID, Equal<Optional<SOOrderFilter.siteID>>,
And<SOShipmentPlan.planDate, LessEqual<Optional<SOOrderFilter.endDate>>,
And<SOShipmentPlan.orderType, Equal<Required<SOOrder.orderType>>,
And<SOShipmentPlan.orderNbr, Equal<Required<SOOrder.orderNbr>>,
And<SOLine.operation, Equal<Required<SOLine.operation>>,
And<SOShipLine.origOrderNbr, IsNull>>>>>>>(this.Base);
List<object> pars = new List<object>(){
siteId,
endDate,
orderType,
orderNbr,
operation
};
bool condition = true;
if(condition)
{
cmd.WhereAnd(typeof(Where<InventoryItem.itemClassID, Equal<Required<InventoryItem.itemClassID>>>));
pars.Add("TEST_ITEM_CLASS");
}
return cmd.Select(pars.ToArray());
*/
}
#endregion
}
}
Upvotes: 1