如何从另一个事件处理程序调用SetPropertyException? [英] How to call SetPropertyException from another event handler?

查看:77
本文介绍了如何从另一个事件处理程序调用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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆