从自定义屏幕

时间:2018-05-04 11:18:17

标签: acumatica

我有一个带有一些值和一个按钮的自定义屏幕,基于我想要打开销售订单和设置订单类型的一些逻辑。能够仅针对SO订单类型执行该操作,因为在首选项屏幕中将SO设置为默认值。我的问题是,如何打开销售订单并将“IN”或“RM”设置为默认值。

SOOrderEntry graph = PXGraph.CreateInstance<SOOrderEntry>();
PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow);

我也试过下面的代码,它也只适用于SO类型,但是它选择了第一个订单作为默认值。

SOOrderEntry docgraph = PXGraph.CreateInstance<SOOrderEntry>();
docgraph.Document.Current = docgraph.Document.Search<SOOrder.orderType>(SOOrderTypeConstants.SalesOrder);
throw new PXRedirectRequiredException(docgraph, true, "Order") { Mode = PXBaseRedirectException.WindowMode.Same };

1 个答案:

答案 0 :(得分:2)

docgraph.Document.Search<SOOrder.orderType>(SOOrderTypeConstants.SalesOrder);此代码将首先返回SalesOrder类型的订单。而不是这样,你可以做以下事情:
1.创建SalesOrder的实例 2.将OrderType的{​​{1}}设置为您需要的SalesOrder 3.将docgraph.Document.Current设置为SalesOrder

您的代码将如下所示(可能需要进行一些更改):

SOOrderEntry docgraph = PXGraph.CreateInstance<SOOrderEntry>();
SOOrder newOrder = docgraph.Document.Insert();//create new Order
newOrder.OrderType = "IN"; // set the OrderType to the one you need.For example "IN"
newOrder = docgrapg.Document.Update(newOrder);//  update the order
docgraph.Document.Current = newOrder;// set your order as the current order of the BLC
throw new PXRedirectRequiredException(docgraph, true, "Order") { Mode = PXBaseRedirectException.WindowMode.Same };
相关问题