【问题标题】:Acumatica - Require File be AttachedAcumatica - 需要附加文件
【发布时间】:2019-08-31 01:52:26
【问题描述】:

在账单和调整中,如果用户尝试保存而不附加/上传文档,则需要显示错误消息“请上传发票”。

我创建了一个不持久的布尔字段 UsrFilesAttached。在 Rowselected 事件中,我得到一个计数,如果为 0,则设置 bool。

我尝试将 AP.APRegister DAC 更新为 [PXUIRequired(typeof(Where>))]

我在 BLC 中尝试了其他东西,但现在找不到。

//in APInvoiceEntry
protected void APInvoice_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
    var inv = (APInvoice)e.Row;
    bool attachedFiles = PXNoteAttribute.GetFileNotes(cache, cache.Current).Length != 0;

    cache.SetValueExt<APRegisterExt.usrFilesAttached>(inv, attachedFiles);  
}

// in DAC AP.APRegister
[PXBool]
[PXUIField(DisplayName="UsrFilesAttached")]
[PXDefault]
[PXUIRequired(typeof(Where<usrFilesAttached, Equal<False>>))]

我希望如果 UsrFilesAttached 为 false 会出现错误。无论 UsrFilesAttached 是真还是假,我都可以保存记录。另外,如何添加自定义错误消息?

【问题讨论】:

    标签: c# acumatica


    【解决方案1】:

    今天早上,我对如何解决这个问题有了不同的想法,它奏效了。我从头开始,它有效:

    protected void APInvoice_Hold_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
    {
      var inv = (APInvoice)e.Row;
      if (inv == null)
        return;
    
      bool attachedFiles = PXNoteAttribute.GetFileNotes(cache, cache.Current).Length != 0;
    
      if (attachedFiles == false)
        {
          cache.RaiseExceptionHandling<APRegister.hold>(inv, null, new PXSetPropertyException("Please attach invoice", PXErrorLevel.Error));
          inv.Hold = true;
        }   
    }
    

    在尝试释放保持时进行检查更有意义。它可能可以改进,所以如果你知道更清洁的方法,请教我。 :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-02
      • 1970-01-01
      • 2023-01-19
      • 1970-01-01
      相关资源
      最近更新 更多