Acumatica 如何从另一个事件处理程序调用SetPropertyException?
下面是我的代码,用于将输入UsrWLAmt字段的任何值插入表示字段值历史记录的BudgetGrid 我想发出警告,提示用户在BudgetGrid历史记录的details字段中输入一个值 受保护的无效PMProject\u UsrWLAmt\u FieldUpdatedPXCache缓存、PXFieldUpdatedEventArgs e、PXFieldUpdatedInvokeBaseHandler { ifInvokeBaseHandler!=null InvokeBaseHandlercache,e; var row=PMProjecte.row; PMProject con=Base.Project.Current; PX.Objects.PM.ProjectExt item=con.GetExtension; 如果item.UsrWLAmt>0 { atcBudgetHis bud=新的atcBudgetHis; bud.CreatedDateTime=DateTime.Now; bud.Value=item.UsrWLAmt; 虎皮鹦鹉; //将异常对象附加到字段的步骤 BudgetGrid.View.Cache.RaiseExceptionHandling 适用于所有行,但不适用于 PXUIFieldAttribute.SetWarningBudgetGrid.Cache,bud,请指定预算更改的原因。; 不会发出任何警告Acumatica 如何从另一个事件处理程序调用SetPropertyException?,acumatica,Acumatica,下面是我的代码,用于将输入UsrWLAmt字段的任何值插入表示字段值历史记录的BudgetGrid 我想发出警告,提示用户在BudgetGrid历史记录的details字段中输入一个值 受保护的无效PMProject\u UsrWLAmt\u FieldUpdatedPXCache缓存、PXFieldUpdatedEventArgs e、PXFieldUpdatedInvokeBaseHandler { ifInvokeBaseHandler!=null InvokeBaseHandlercac
我可以在网格上方为要插入的注释创建另一个字段,但是有没有办法为BudgetGird中的最后一行设置警告?似乎您试图在调用事件时网格中不存在的DAC实例上设置警告 您是否尝试过在事件处理程序参数中返回的现有行上设置警告
PXUIFieldAttribute.SetWarning<atcBudgetHis.details>(BudgetGrid.Cache, row, "Please specify reason for budget change.");
警告适用于满足执行此行条件的所有行。如果只想显示最后一行,则必须手动检查参数中接收到的行是否与数据视图中的最后一行相同,然后才对该行执行警告。您似乎试图将警告设置为n调用事件时网格中不存在的DAC实例 您是否尝试过在事件处理程序参数中返回的现有行上设置警告
PXUIFieldAttribute.SetWarning<atcBudgetHis.details>(BudgetGrid.Cache, row, "Please specify reason for budget change.");
警告适用于满足执行此行条件的所有行。如果只想显示最后一行,则必须手动检查参数中接收到的行是否与数据视图中的最后一行相同,然后才对该行执行警告。解决方案是使用插入的行为我的网格输入ent并将行变量传递到SetWarning中解决方案是为我的网格使用RowInserted事件并将行变量传递到SetWarning中首先,要在Acumatica中显示警告,必须使用以下事件之一: FieldVerification并抛出PXSetPropertyException,此时警告只应在用户更新记录期间出现 如果警告仅在用户更新记录期间出现在多个字段上,则在PXCache上调用RaiseExceptionHandling方法进行行更新 在PXCache上调用RaiseExceptionHandling方法时选择RowSelected,如果警告应始终出现在多个字段上,直到用户解决了警告的原因 我想对于您的特定场景,RowSelected可能最适合在Notes列中不断显示所有空单元格的警告:
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);
}
}
首先,要在针灸中显示警告,必须使用以下事件之一: FieldVerification并抛出PXSetPropertyException,此时警告只应在用户更新记录期间出现 如果警告仅在用户更新记录期间出现在多个字段上,则在PXCache上调用RaiseExceptionHandling方法进行行更新 在PXCache上调用RaiseExceptionHandling方法时选择RowSelected,如果警告应始终出现在多个字段上,直到用户解决了警告的原因 我想对于您的特定场景,RowSelected可能最适合在Notes列中不断显示所有空单元格的警告:
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);
}
}
您需要更改此代码:
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));
对这样的事情:
bud = BudgetGrid.Insert(bud); //you need to get the "bud" which is in the cache
// 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.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));
对这样的事情:
bud = BudgetGrid.Insert(bud); //you need to get the "bud" which is in the cache
// 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));
谢谢,但此事件是由位于我的PXGrid上方的字段触发的。在SetWarning中使用row作为第二个参数,不会发出警告,也不会出现错误,因为它在AtcBudget中查找PMProject。谢谢,但此事件是由位于我的PXGrid上方的字段触发的。在SetWarning中使用row作为第二个参数,不会发出警告,也不会出现错误o错误,因为它正在ATCBUDGETHS DAC中查找PMProject