2017-01-29 38 views
0

下面是我的代碼插入任何值輸入到我的UsrWLAmt字段到我的BudgetGrid代表的字段值的歷史。如何從另一個事件處理函數調用SetPropertyException?

我想提出一個警告,提示用戶在BudgetGrid歷史

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

上面的代碼沒有按不會產生任何跟蹤錯誤。

編輯:

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

enter image description here

適用於所有的行,但

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

不提出任何警告。

我可以在網格上方爲插入的音符創建另一個字段,但是有沒有辦法可以爲BudgetGird中的最後一行設置警告?

回答

1

看起來好像你試圖在事件被調用時網格中不存在的DAC實例上設置警告。

您是否曾嘗試在事件處理程序參數中返回的現有行上設置警告?

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

該警告適用於滿足執行此行的條件的所有行。如果只想顯示最後一行,則必須手動檢查參數中收到的行是否與數據視圖中的最後一行相同,然後才執行該行的警告。

+0

謝謝,但這一事件是由場上面坐着我PXGrid觸發。在SetWarning中使用行作爲第二個參數,因爲它在atcBudgetHis DAC中查找PMProject,所以不會發出警告和錯誤 – nickivey

1

第一件事使用RowInserted事件對我的網格,並通過該行可變進SetWarning,以示警告在Acumatica以下事件之一必須使用:

  • FieldVerifying扔PXSetPropertyException,警告時間用戶中應該只出現在更新記錄

  • RowUpd僅在時間用戶阿婷與調用上PXCache RaiseExceptionHandling方法,如果警告應該出現在多個字段更新記錄

  • RowSelected與調用上PXCache,如果警告應該出現在多個領域的所有時間,直到RaiseExceptionHandling方法用戶解決警告的原因

我想爲您的特定情況下,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); 
    } 
} 
0

您需要更改此代碼:

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)); 
相關問題