如何从另一个事件处理程序调用SetPropertyException?

编程入门 行业动态 更新时间:2024-10-27 18:25:05
本文介绍了如何从另一个事件处理程序调用SetPropertyException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

下面是我的代码,将输入到UsrWLAmt字段中的任何值插入到我的BudgetGrid中,代表字段值的历史记录。

Below is my code to insert whatever value is entered into my UsrWLAmt field into my BudgetGrid representing the history of the fields values.

我想引发警告,提示用户在BudgetGrid历史记录的详细信息字段中输入值

I want to raise a warning prompting the user to enter a value into the details field in the BudgetGrid History

protected void PMProject_UsrWLAmt_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler) { if(InvokeBaseHandler != null) InvokeBaseHandler(cache, e); var row = (PMProject)e.Row; PMProject con = Base.Project.Current; PX.Objects.PM.ProjectExt item = con.GetExtension<PX.Objects.PM.ProjectExt>(); if (item.UsrWLAmt > 0) { atcBudgetHis bud = new atcBudgetHis(); bud.CreatedDateTime = DateTime.Now; bud.Value = item.UsrWLAmt; BudgetGrid.Insert(bud); // to attach the exception object to the field BudgetGrid.View.Cache.RaiseExceptionHandling<atcBudgetHis.details>( bud, " ", new PXSetPropertyException( "Please specifiy reason for budget change.", PXErrorLevel.Warning)); } }

我也尝试了BudgetGrid。 Cahce.RaiseExceptionHandling

I've also tried BudgetGrid.Cahce.RaiseExceptionHandling

上面的代码不会引发任何跟踪错误。

The code above doesn't raise any trace errors.

编辑:

PXUIFieldAttribute.SetWarning<atcBudgetHis.details>(BudgetGrid.Cache, null, "Please specifiy reason for budget change.");

可用于所有行,但

PXUIFieldAttribute.SetWarning<atcBudgetHis.details>(BudgetGrid.Cache, bud, "Please specifiy reason for budget change.");

不发出任何警告。

我可以在网格上方为要插入的注释创建另一个字段,但是有没有办法为BudgetGird中的最后一行设置警告?

I could create another field above the grid for the notes to be inserted, but is there a way I can set the warning for the last row in the BudgetGird?

推荐答案

首先,要在Acumatica中显示警告,必须使用以下事件之一:

First things first, to show a warning in Acumatica one of the following events must be used:

  • FieldVerifying 并抛出PXSetPropertyException,当警告仅在用户更新记录时出现

  • FieldVerifying and throw PXSetPropertyException, when warning should appear only during the time user updates a record

RowUpdating ,并在PXCache上调用了RaiseExceptionHandling方法,如果警告仅在用户更新记录期间出现在多个字段上

RowUpdating with RaiseExceptionHandling method invoked on PXCache, if warning should appear on multiple fields only during the time user updates a record

RowSelected ,并且在PXCache上调用了RaiseExceptionHandling方法,如果警告应该一直出现在多个字段上,直到用户解决警告的原因为止

RowSelected with RaiseExceptionHandling method invoked on PXCache, if warning should appear on multiple fields all the time until a user addresses the cause of warning

我想对于您的特定情况,RowSelected可能最适合不断显示警告注释字段中所有空单元格的s:

I guess for your particular scenario, RowSelected might work best to constantly show warnings for all empty cells within Notes column:

public void atcBudgetHis_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { atcBudgetHis row = e.Row as atcBudgetHis; if (row == null) return; if (string.IsNullOrEmpty(row.Details)) { sender.RaiseExceptionHandling<atcBudgetHis.details>(row, string.Empty, new PXSetPropertyException("Please specify reason for budget change.", PXErrorLevel.Warning)); } else { sender.RaiseExceptionHandling<atcBudgetHis.details>(row, row.Details, null); } }

更多推荐

如何从另一个事件处理程序调用SetPropertyException?

本文发布于:2023-11-09 15:01:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1572673.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:事件   程序   SetPropertyException

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!