While you are no doubt adding the records to the cache in the order that you intend, the UI is defaulting to the ordering stipulated (or defaulted) by the view. I would try overriding the View definition and adding the orderby clause.
HI Patrick, thank you for the suggestion. I made changes you recommended, and overrode the SOCreateShipment method BuildCommandCreateShipment(). but I am still not seeing the order data sorted by the SOOrder.RequestDate. It is still sorting on the display based on SOOrder DAC primary key. Here is the overriden method call in SOCreateShipment_Extension:
public PXSelectBase<SOOrder> BuildCommandCreateShipment(SOOrderFilter filter, BuildCommandCreateShipmentDelegate baseMethod)
{
// Approach 2 - Replace entire method, and add OrderBy to the View
SOCreateShipment baseGraph = Base;
PXSelectBase<SOOrder> cmd = new PXSelectJoinGroupBy<SOOrder,
LeftJoin<Carrier, On<SOOrder.shipVia, Equal<Carrier.carrierID>>,
InnerJoin<SOShipmentPlan,
On<SOOrder.orderType, Equal<SOShipmentPlan.orderType>,
And<SOOrder.orderNbr, Equal<SOShipmentPlan.orderNbr>>>,
InnerJoin<INSite, On<INSite.siteID, Equal<SOShipmentPlan.siteID>>,
LeftJoin<SOOrderShipment,
On<SOOrderShipment.orderType, Equal<SOShipmentPlan.orderType>,
And<SOOrderShipment.orderNbr, Equal<SOShipmentPlan.orderNbr>,
And<SOOrderShipment.siteID, Equal<SOShipmentPlan.siteID>,
And<SOOrderShipment.confirmed, Equal<boolFalse>>>>>,
LeftJoinSingleTable<Customer, On<SOOrder.customerID, Equal<Customer.bAccountID>>>>>>>,
Where<SOShipmentPlan.inclQtySOBackOrdered, Equal<short0>, And<SOOrderShipment.shipmentNbr, IsNull,
And<SOOrder.status, NotEqual<SOOrderStatus.shipping>,
And2<Where<Customer.bAccountID, IsNull, Or<Match<Customer, Current<AccessInfo.userName>>>>,
And<Match<INSite, Current<AccessInfo.userName>>>>>>>,
Aggregate<
GroupBy<SOOrder.orderType,
GroupBy<SOOrder.orderNbr,
GroupBy<SOOrder.approved>>>>,
OrderBy<Asc<SOOrder.requestDate>>>(baseGraph);
string errmsg = "cmd value is: " + cmd.ToString();
PXTrace.WriteInformation(errmsg);
if (filter.SiteID != null)
cmd.WhereAnd<Where<SOShipmentPlan.siteID, Equal<Current<SOOrderFilter.siteID>>>>();
if (filter.DateSel == "S")
{
if (filter.EndDate != null)
cmd.WhereAnd<Where<SOShipmentPlan.planDate, LessEqual<Current<SOOrderFilter.endDate>>>>();
if (filter.StartDate != null)
{
cmd.WhereAnd<Where<SOShipmentPlan.planDate, GreaterEqual<Current<SOOrderFilter.startDate>>>>();
}
filter.DateSel = string.Empty;
}
return cmd;
}
The SOCreateShipment program uses a delegate method to generate the Data View. Could that be the reason the OrderBy is not working?
Randy
Attached is the trace that was generated.
I am talking about overriding the Orders view definition
Sorry, I guess I’m confused. I was thinking this IS the View definition? The only other reference I see in SOCreateShipment for ‘Orders’ is:
public class SOCreateShipment : PXGraph<SOCreateShipment>
{
public PXCancel<SOOrderFilter> Cancel;
public PXAction<SOOrderFilter> viewDocument;
public PXFilter<SOOrderFilter> Filter;
lPXFilterable]
public PXFilteredProcessing<SOOrder, SOOrderFilter> Orders;
Is this what you are referring to? How would I add an OrderBy here?
I made this redefinition of the DataView (original is above in Red):
public PXFilteredProcessing<SOOrder, SOOrderFilter,
Where<SOOrder.status, NotEqual<SOOrderStatus.shipping>>,
OrderBy<Asc<SOOrder.requestDate>>> Orders;
This DOES now show the list of orders in RequestDate order. However,
- I only wanted to supply the ‘OrderBy’ clause, but it required me to also supply the ‘Where’ clause.
- When I supply the Where clause, the actual filter is overriding the Where clause defined in the Delegate view (ie the ‘orders() method’. Is there a way to add only an ‘OrderBy’?
Not that I know of: Where<True, IsEqual<True» always works ;)
Patrick,
After following your suggestions, and redefining the DataView in SOCreateShipment_Extension, I have discovered that the view delegate (defined in the base SOCreateShipment as orders()) logic is no longer being executed, when using the Visual Studio debugger. If I remove my redefinition, and debug again, the delegate view method IS BEING executed. Does this mean that if you redefine the data view, you must ALSO redefine the view delegate?
Here again is the Data View redefinition in my extension:
public class SOCreateShipment_Extension : PXGraphExtension<SOCreateShipment>
{
#region Data Views
/PXFilterable]
public PXFilteredProcessing<SOOrder, SOOrderFilter,
Where<True, Equal<True>>,
OrderBy<Asc<SOOrder.requestDate>>> Orders;
#endregion
#region isActive
public static bool IsActive()
{
return true;
}
#endregion
}