1

我在 VendOpenTrans 上有一个按钮并实现了它的 clicked 方法。

我认为这会起作用,但我得到一个异常并且 AX 关闭..

void clicked()
{
   LedgerJournalTrans ledgerJournalTrans;
   VendTransOpen vto;

   super();

   switch (originator.TableId)
   {
      case tableNum(LedgerJournalTrans):
          ledgerJournalTrans = element.args().record();
    }



for ( vto = vendTransOpen_ds.getFirst(0); vto; vto = vendTransOpen_ds.getNext() )
{
    //vendTransOpen_ds.markRecord(vto, 1);
    if (vto.RecId)
    {
        if (manager.getTransMarked(vto) == NoYes::No)
        {
           select Invoice from vendTrans
               where vto.AccountNum == vendTrans.AccountNum &&
                 vto.RefRecId == vendTrans.RecId;

              if (ledgerJournalTrans.Invoice == vendTrans.Invoice)
              {
                // Mark transaction for settlement
                 showError = NoYes::No;
                 manager.updateTransMarked(vto, NoYes::Yes);
                 showError = NoYes::Yes;
              }
          }
      }

    // Update dynamic controls & refresh form as auto-redraw is not triggered
     element.updateDesignDynamic();
     element.redraw();

 }
vendTransOpen_ds.refreshEx(-2);
}

如果我注释掉以下行,它将起作用,基本上标记网格中的所有行。

//select Invoice from vendTrans
     //where vto.AccountNum == vendTrans.AccountNum &&
          //vto.RefRecId == vendTrans.RecId;

//if (ledgerJournalTrans.Invoice == vendTrans.Invoice)
//{
     // Mark transaction for settlement
        showError = NoYes::No;
        manager.updateTransMarked(vto, NoYes::Yes);
        showError = NoYes::Yes;
//}

因此,更清楚地说,留下的是:manager.updateTransMarked(vto, NoYes::Yes);

这样,它就可以工作了。据我所知,当我添加该选择时会发生一些事情。

使用调试我能够检查它,我认为异常是由 for 循环引发的..

有没有机会得到这个提示?

4

1 回答 1

2

尝试将您的 for 循环定义更改为:

for (vto = vendTransOpen_ds.getFirst(0) ? vendTransOpen_ds.getFirst(0) : vendTransOpen_ds.cursor(); vto; vto = vendTransOpen_ds.getNext())

并改变这个:

select Invoice from vendTrans
    where vto.AccountNum == vendTrans.AccountNum &&
          vto.RefRecId == vendTrans.RecId;

    if (ledgerJournalTrans.Invoice == vendTrans.Invoice)
    {

对此:

if (ledgerJournalTrans.Invoice == vto.vendTrans().Invoice)
于 2015-12-17T17:01:05.673 回答