I have created a screen to change items in a sales order using a processing screen
The top of the form has two fields, the “From” item and the “To” item.
When you kick off the PROCESS ALL, I need to have the values in those fields available to the process delegate.

Since the UpdateOrders delegate is static, I don’t know how to get the from and to item numbers. I’ve tried creating public properties and setting the values of the properties on the rowselected event. But when UpdateOrders fires, and ultimately fires the UpdateOrder method, the properties are null.
In the code below, I hard coded the inventoryID’s just to verify the code actually changes the sales order and it works great. I just don’t know how to access the values in the top of the screen in the code.
ItemNumberToChangeFilter filterValues = Filter.Select(); returns nulls.
Other than that, I’m almost done! :-)
public PXFilter<ItemNumberToChangeFilter> Filter;
public PXFilteredProcessingJoin<SOOrder, ItemNumberToChangeFilter,
LeftJoin<SOLine, On<SOLine.orderNbr.IsEqual<SOOrder.orderNbr>>>,
Where<SOOrder.status.IsEqual<SOOrderStatus.open>
.And<SOOrder.completed.IsEqual<False>>
.And<SOOrder.orderType.IsEqual<SOOrderTypeConstants.salesOrder>>
.And<SOLine.inventoryID.IsEqual<ItemNumberToChangeFilter.inventoryOld.FromCurrent>>>,
OrderBy<SOOrder.orderNbr.Desc>> OrdersToProcess;
[Serializable]
//[PXHidden]
[PXCacheName("Filtering Fields")]
public class ItemNumberToChangeFilter : IBqlTable
{
#region InventoryOld
[Inventory]
[PXUIField(DisplayName = "Original Item ID")]
public virtual int? InventoryOld { get; set; }
public abstract class inventoryOld : PX.Data.BQL.BqlInt.Field<inventoryOld> { }
#endregion
#region InventoryNew
[Inventory]
[PXUIField(DisplayName = "New Item ID")]
public virtual int? InventoryNew { get; set; }
public abstract class inventoryNew : PX.Data.BQL.BqlInt.Field<inventoryNew> { }
#endregion
}
public ICSSalesOrderItemChange()
{
OrdersToProcess.SetProcessDelegate(UpdateOrders);
}
public static void UpdateOrders(List<SOOrder> ordersToProcess)
{
using (var ts = new PXTransactionScope())
{
ICSSalesOrderItemChange graph = PXGraph.CreateInstance<ICSSalesOrderItemChange>();
PXLongOperation.StartOperation(graph, delegate ()
{
foreach (SOOrder order in ordersToProcess)
{
try
{
graph.UpdateOrder(order, true);
}
catch (Exception e)
{
PXProcessing<SOOrder>.SetError(ordersToProcess.IndexOf(order), e);
}
}
});
ts.Complete();
}
}
public void UpdateOrder(SOOrder order, bool isMassProcess = false)
{
SOOrderEntry graph = PXGraph.CreateInstance<SOOrderEntry>();
graph.Clear();
graph.Document.Select(order);
ItemNumberToChangeFilter filterValues = Filter.Select();
foreach(SOLine line in graph.Transactions.Select())
{
decimal? quantity = line.OrderQty;
//if (line.InventoryID == filterValues.InventoryOld)
if (line.InventoryID == 691)
{
graph.Transactions.Delete(line);
var doc = new SOLine()
{
OrderType = order.OrderType,
OrderNbr = order.OrderNbr
};
doc = graph.Transactions.Insert(doc);
//doc.InventoryID = filterValues.InventoryNew;
doc.InventoryID = 693;
doc.OrderQty = quantity;
graph.Transactions.Update(doc);
}
}
graph.Actions.PressSave();
if (isMassProcess)
{
PXProcessing.SetInfo(string.Format("Updated", order.OrderNbr));
}
}