Acumatica 需要遍历SO线-并使用自定义字段进行检查
只有当SO行表中的某些自定义字段被输入并与其他一些表一起检查时,我才需要将销售订单标记为打开 我创造了一个事件- 如何在此处遍历SO线及其扩展字段Acumatica 需要遍历SO线-并使用自定义字段进行检查,acumatica,Acumatica,只有当SO行表中的某些自定义字段被输入并与其他一些表一起检查时,我才需要将销售订单标记为打开 我创造了一个事件- 如何在此处遍历SO线及其扩展字段 // protected void SOOrder_Hold_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler) // { // if(InvokeBaseHandler != null) //
// protected void SOOrder_Hold_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
// {
// if(InvokeBaseHandler != null)
// InvokeBaseHandler(cache, e);
// var row = (SOOrder)e.Row;
// string ordtype = row.OrderType;
// string ordnbr = row.OrderNbr;
// if (row.Hold == false)/
// {
// foreach (SOLine record in
// PXSelectReadonly<SOLine,
// Where<SOLine.orderType, Equal<Required<SOLine.orderType>>,
// And<SOLine.orderNbr, Equal<Required<SOLine.orderNbr>>>>>.Select(Base, ordtype, ordnbr))
// {
// cache.RaiseExceptionHandling<SOOrder.hold>(
// row, row.Hold,
// new PXSetPropertyException("Product Module Sample Project Check", PXErrorLevel.Warning));
// }
// }
// }
SO行存储在SOOrderEntryGraph的事务数据视图中。 要使用它们并检查扩展中的任何自定义字段,可以执行以下操作:
protected void SOOrder_Hold_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
{
//if(InvokeBaseHandler!=null) - remove comments from these lines if you need to call the base method
// InvokeBaseHandler(cache,e);
if(e.Row!=null)
{
SOOrder currentOrder = (SOOrder) e.Row;
foreach (IEnumerator<PXResultSet<SOLine>> linesEnumerator in this.Base.Transactions.Select().GetEnumerator())
{
while (linesEnumerator.MoveNext())
{
SOLine currentLine = (SOLine)linesEnumerator.Current;
var currentLineExt = PXCache<SOLine>.GetExtension<SOLineExt>(currentLine);// replace SOLineExt with the name of your DAC's Cache Extension's class name
//----
// Here add your checking
//----
}
}
}
}
SO行存储在SOOrderEntryGraph的事务数据视图中。 要使用它们并检查扩展中的任何自定义字段,可以执行以下操作:
protected void SOOrder_Hold_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
{
//if(InvokeBaseHandler!=null) - remove comments from these lines if you need to call the base method
// InvokeBaseHandler(cache,e);
if(e.Row!=null)
{
SOOrder currentOrder = (SOOrder) e.Row;
foreach (IEnumerator<PXResultSet<SOLine>> linesEnumerator in this.Base.Transactions.Select().GetEnumerator())
{
while (linesEnumerator.MoveNext())
{
SOLine currentLine = (SOLine)linesEnumerator.Current;
var currentLineExt = PXCache<SOLine>.GetExtension<SOLineExt>(currentLine);// replace SOLineExt with the name of your DAC's Cache Extension's class name
//----
// Here add your checking
//----
}
}
}
}
实际上,我建议使用FieldVerification事件
protected virtual void SOOrder_Hold_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e, PXFieldVerifying del)
{
//Calls other handlers if they exist.
//Important for Acumatica Events / Other Customizations
if (del != null)
{
del(sender, e);
}
SOOrder row = e.Row as SOOrder;
if (row != null && !((e.NewValue as bool?) ?? false))
{
bool allFieldsProper = true;
SOLine line;
SOLineExtension lineExt;
foreach (PXResult<SOLine, INItemCost> res in Base.Transactions.Select())
{
line = res[0] as SOLine;
lineExt = line.GetExtension<SOLineExtension>();
if (lineExt.UsrField != "Some Value")
{
allFieldsProper = false;
//No point in further evaluation if 1 is wrong
break;
}
}
if (!allFieldsProper)
{
throw new PXSetPropertyException<SOOrder.hold>("Error", PXErrorLevel.Error)
}
}
}
实际上,我建议使用FieldVerification事件
protected virtual void SOOrder_Hold_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e, PXFieldVerifying del)
{
//Calls other handlers if they exist.
//Important for Acumatica Events / Other Customizations
if (del != null)
{
del(sender, e);
}
SOOrder row = e.Row as SOOrder;
if (row != null && !((e.NewValue as bool?) ?? false))
{
bool allFieldsProper = true;
SOLine line;
SOLineExtension lineExt;
foreach (PXResult<SOLine, INItemCost> res in Base.Transactions.Select())
{
line = res[0] as SOLine;
lineExt = line.GetExtension<SOLineExtension>();
if (lineExt.UsrField != "Some Value")
{
allFieldsProper = false;
//No point in further evaluation if 1 is wrong
break;
}
}
if (!allFieldsProper)
{
throw new PXSetPropertyException<SOOrder.hold>("Error", PXErrorLevel.Error)
}
}
}
基于用户问题和发布代码的良好现场验证推荐基于用户问题和发布代码的良好现场验证推荐