Acumatica 如何在确认装运后以编程方式调用更新?
当用户向发货发送订单时,我需要调用“上载”操作。我已经自动确认了订单。这是我的代码,它基于一个不同问题的答案():Acumatica 如何在确认装运后以编程方式调用更新?,acumatica,Acumatica,当用户向发货发送订单时,我需要调用“上载”操作。我已经自动确认了订单。这是我的代码,它基于一个不同问题的答案(): public delegate void CreateShipmentDelegate(订单顺序、int?SiteID、DateTime?ShipDate、bool?useOptimalShipDate、字符串操作、文档列表); [PXOverride] 公共虚拟void createShipping(SOOrder order、int?SiteID、DateTime?ShipDa
public delegate void CreateShipmentDelegate(订单顺序、int?SiteID、DateTime?ShipDate、bool?useOptimalShipDate、字符串操作、文档列表);
[PXOverride]
公共虚拟void createShipping(SOOrder order、int?SiteID、DateTime?ShipDate、bool?USEOTIMATICSHIPDATE、字符串操作、文档列表、CreateShipmentDelegate baseMethod)
{
baseMethod(订单、站点ID、发货日期、使用优化发货日期、操作、列表);
foreach(var action in(Base.action.GetState(null)作为PXButtonState)。菜单)
{
如果(action.Command==“确认装运”)
{
PXAdapter adapter2=新PXAdapter(新DummyView(Base,Base.Document.View.BqlSelect,新列表{Base.Document.Current});
adapter2.Menu=action.Command;
底座。动作。按下按钮(适配器2);
时间跨度时间跨度;
例外情况;
while(PXLongOperation.GetStatus(Base.UID,out timespan,out ex)==PXLongRunStatus.InProcess)
{ }
打破
}
}
}
我试图复制foreach循环,但搜索“Upload IN”,但没有得到预期的结果:
foreach (var action in (Base.action.GetState(null) as PXButtonState).Menus)
{
if (action.Command == "Update IN")
{
PXAdapter adapter3 = new PXAdapter(new DummyView(Base, Base.Document.View.BqlSelect, new List<object> { Base.Document.Current }));
adapter3.Menu = action.Command;
Base.action.PressButton(adapter3);
TimeSpan timespan;
Exception ex;
while (PXLongOperation.GetStatus(Base.UID, out timespan, out ex) == PXLongRunStatus.InProcess)
{ }
break;
}
}
foreach(菜单中的var action(Base.action.GetState(null)为PXButtonState)
{
如果(action.Command==“更新中”)
{
PXAdapter adapter3=新PXAdapter(新DummyView(Base,Base.Document.View.BqlSelect,新列表{Base.Document.Current});
adapter3.Menu=action.Command;
底座。动作。按下按钮(适配器3);
时间跨度时间跨度;
例外情况;
while(PXLongOperation.GetStatus(Base.UID,out timespan,out ex)==PXLongRunStatus.InProcess)
{ }
打破
}
}
一般来说,还有其他方法可以调用操作吗
我注意到这个特定操作的一点是,我在版本6实例的源代码中找不到它的代码,但在版本2017中,我发现它是自己的操作,但可见性=false。此操作在2017年是否已过时,或者是否有在配置中显示/隐藏此操作的设置?2017年早期版本中存在一个已知错误,该操作实际上在屏幕上不可见: 此错误应在2017年最新版本中修复。同时,解决方法是在SOShipmentEntry图扩展中重新定义该操作。使用该代码,操作将可见,因此可以:
[PXUIField(DisplayName = "Update IN", Visible = false, MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXButton]
protected virtual IEnumerable updateIN(PXAdapter adapter, List<SOShipment> shipmentList = null)
{
List<SOShipment> list = new List<SOShipment>();
if (shipmentList == null)
{
foreach (SOShipment order in adapter.Get<SOShipment>())
{
list.Add(order);
}
}
else
{
list = shipmentList;
}
if (!Base.UnattendedMode && sosetup.Current.UseShippedNotInvoiced != true && sosetup.Current.UseShipDateForInvoiceDate != true && list.Any(shipment =>
{
IReadOnlyDictionary<string, object> fills = PXAutomation.GetFills(shipment);
object fillStatus = null;
fills?.TryGetValue(typeof(SOShipment.status).Name, out fillStatus);
return shipment.Status != SOShipmentStatus.Completed && fillStatus?.ToString() != SOShipmentStatus.Completed;
}))
{
WebDialogResult result = Base.Document.View.Ask(Base.Document.Current, PX.Objects.GL.Messages.Confirmation,
PX.Objects.SO.Messages.ShipNotInvoicedUpdateIN, MessageButtons.YesNo, MessageIcon.Question);
if (result != WebDialogResult.Yes)
return list;
}
Base.Save.Press();
PXLongOperation.StartOperation(this, delegate ()
{
INIssueEntry ie = PXGraph.CreateInstance<INIssueEntry>();
SOShipmentEntry docgraph = PXGraph.CreateInstance<SOShipmentEntry>();
docgraph.Caches[typeof(SiteStatus)] = ie.Caches[typeof(SiteStatus)];
docgraph.Caches[typeof(LocationStatus)] = ie.Caches[typeof(LocationStatus)];
docgraph.Caches[typeof(LotSerialStatus)] = ie.Caches[typeof(LotSerialStatus)];
docgraph.Caches[typeof(SiteLotSerial)] = ie.Caches[typeof(SiteLotSerial)];
docgraph.Caches[typeof(ItemLotSerial)] = ie.Caches[typeof(ItemLotSerial)];
docgraph.Views.Caches.Remove(typeof(SiteStatus));
docgraph.Views.Caches.Remove(typeof(LocationStatus));
docgraph.Views.Caches.Remove(typeof(LotSerialStatus));
docgraph.Views.Caches.Remove(typeof(SiteLotSerial));
docgraph.Views.Caches.Remove(typeof(ItemLotSerial));
DocumentList<INRegister> created = new DocumentList<INRegister>(docgraph);
foreach (SOShipment order in list)
{
try
{
if (adapter.MassProcess) PXProcessing<SOShipment>.SetCurrentItem(order);
docgraph.PostShipment(ie, order, created);
}
catch (Exception ex)
{
if (!adapter.MassProcess)
{
throw;
}
PXProcessing<SOShipment>.SetError(ex);
}
}
if (docgraph.sosetup.Current.AutoReleaseIN == true && created.Count > 0 && created[0].Hold == false)
{
INDocumentRelease.ReleaseDoc(created, false);
}
});
return list;
}
[PXUIField(DisplayName=“updatein”,Visible=false,MapEnableRights=PXCacheRights.Select,MapViewRights=PXCacheRights.Select)]
[按钮]
受保护的虚拟IEnumerable updateIN(PXAdapter适配器,List shipmentList=null)
{
列表=新列表();
如果(shipmentList==null)
{
foreach(适配器.Get()中的SoShipping order)
{
列表。添加(订单);
}
}
其他的
{
列表=发货列表;
}
如果(!Base.UnattendedMode&&sosetup.Current.UseShippedNotInvoinced!=true&&sosetup.Current.UseShippedDateForInvoiceDate!=true&&list.Any(装运=>
{
IReadOnlyDictionary fills=PXAutomation.GetFills(装运);
对象fillStatus=null;
填充?.TryGetValue(typeof(soshipping.status).Name,out fillStatus);
退货装运。状态!=SOShipmentStatus.Completed&&fillStatus?.ToString()!=SOShipmentStatus.Completed;
}))
{
WebDialogResult=Base.Document.View.Ask(Base.Document.Current,PX.Objects.GL.Messages.Confirmation,
PX.Objects.SO.Messages.ShipNotInvoicedUpdateIN,MessageButtons.YesNo,MessageIcon.Question);
if(result!=WebDialogResult.Yes)
退货清单;
}
Base.Save.Press();
PXLongOperation.StartOperation(此,委托()
{
INIssueEntry ie=PXGraph.CreateInstance();
SOShipmentEntry docgraph=PXGraph.CreateInstance();
docgraph.Caches[typeof(SiteStatus)]=ie.Caches[typeof(SiteStatus)];
docgraph.Caches[typeof(LocationStatus)]=ie.Caches[typeof(LocationStatus)];
docgraph.Caches[typeof(LotSerialStatus)]=ie.Caches[typeof(LotSerialStatus)];
docgraph.Caches[typeof(SiteLotSerial)]=ie.Caches[typeof(SiteLotSerial)];
docgraph.Caches[typeof(ItemLotSerial)]=ie.Caches[typeof(ItemLotSerial)];
docgraph.Views.Caches.Remove(typeof(SiteStatus));
docgraph.Views.Caches.Remove(typeof(LocationStatus));
docgraph.Views.Caches.Remove(typeof(LotSerialStatus));
docgraph.Views.Caches.Remove(typeof(SiteLotSerial));
docgraph.Views.Caches.Remove(typeof(ItemLotSerial));
创建的文档列表=新文档列表(docgraph);
foreach(SOS列表中的装运订单)
{
尝试
{
if(adapter.MassProcess)PXProcessing.SetCurrentItem(订单);
装运后(即,订单,已创建);
}
捕获(例外情况除外)
{
if(!adapter.MassProcess)
{
投
}
PXProcessing.SetError(ex);
}
}
if(docgraph.sosetup.Current.AutoReleaseIN==true&&created.Count>0&&created[0]。Hold==false)
{
INDocumentRelease.ReleaseDoc(已创建,false);
}
});
退货清单;
}
我相信操作已经从自动化步骤(v6.x)转移到了v2017的实际源代码中。在移动过程中,字段修改器被设置为受保护或私有,这使得它在沿着这些线扩展图形或其他内容时消失。添加tha
[PXUIField(DisplayName = "Update IN", Visible = false, MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXButton]
protected virtual IEnumerable updateIN(PXAdapter adapter, List<SOShipment> shipmentList = null)
{
List<SOShipment> list = new List<SOShipment>();
if (shipmentList == null)
{
foreach (SOShipment order in adapter.Get<SOShipment>())
{
list.Add(order);
}
}
else
{
list = shipmentList;
}
if (!Base.UnattendedMode && sosetup.Current.UseShippedNotInvoiced != true && sosetup.Current.UseShipDateForInvoiceDate != true && list.Any(shipment =>
{
IReadOnlyDictionary<string, object> fills = PXAutomation.GetFills(shipment);
object fillStatus = null;
fills?.TryGetValue(typeof(SOShipment.status).Name, out fillStatus);
return shipment.Status != SOShipmentStatus.Completed && fillStatus?.ToString() != SOShipmentStatus.Completed;
}))
{
WebDialogResult result = Base.Document.View.Ask(Base.Document.Current, PX.Objects.GL.Messages.Confirmation,
PX.Objects.SO.Messages.ShipNotInvoicedUpdateIN, MessageButtons.YesNo, MessageIcon.Question);
if (result != WebDialogResult.Yes)
return list;
}
Base.Save.Press();
PXLongOperation.StartOperation(this, delegate ()
{
INIssueEntry ie = PXGraph.CreateInstance<INIssueEntry>();
SOShipmentEntry docgraph = PXGraph.CreateInstance<SOShipmentEntry>();
docgraph.Caches[typeof(SiteStatus)] = ie.Caches[typeof(SiteStatus)];
docgraph.Caches[typeof(LocationStatus)] = ie.Caches[typeof(LocationStatus)];
docgraph.Caches[typeof(LotSerialStatus)] = ie.Caches[typeof(LotSerialStatus)];
docgraph.Caches[typeof(SiteLotSerial)] = ie.Caches[typeof(SiteLotSerial)];
docgraph.Caches[typeof(ItemLotSerial)] = ie.Caches[typeof(ItemLotSerial)];
docgraph.Views.Caches.Remove(typeof(SiteStatus));
docgraph.Views.Caches.Remove(typeof(LocationStatus));
docgraph.Views.Caches.Remove(typeof(LotSerialStatus));
docgraph.Views.Caches.Remove(typeof(SiteLotSerial));
docgraph.Views.Caches.Remove(typeof(ItemLotSerial));
DocumentList<INRegister> created = new DocumentList<INRegister>(docgraph);
foreach (SOShipment order in list)
{
try
{
if (adapter.MassProcess) PXProcessing<SOShipment>.SetCurrentItem(order);
docgraph.PostShipment(ie, order, created);
}
catch (Exception ex)
{
if (!adapter.MassProcess)
{
throw;
}
PXProcessing<SOShipment>.SetError(ex);
}
}
if (docgraph.sosetup.Current.AutoReleaseIN == true && created.Count > 0 && created[0].Hold == false)
{
INDocumentRelease.ReleaseDoc(created, false);
}
});
return list;
}