web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Am I able to update table BANKCHEQUETABLE using a custom script?

(0) ShareShare
ReportReport
Posted on by 624

I am attempting to update a check status to "Void" in the table BANKCHEQUETABLE using a custom script class job.  When I execute it in Sandbox, I receive the message, "The custom script is not allowed to access the BankChequeTable table."  Does anyone know if this table is accessible to update via a custom script? 

I have the same question (0)
  • Oceanfish26 Profile Picture
    624 on at

    Response from Microsoft, "Finance team confirmed that bankchequetable cannot be used with X++ custom scripts as there are some tables that naturally prevent execution."

    Looks like it just cannot be done.

    Thank you, for your time and help.

  • Oceanfish26 Profile Picture
    624 on at

    Thanks again, I'll give it a try now.

  • Suggested answer
    SARFARAZ AHMED MUFTI Profile Picture
    32 on at

    public static void main(args _args)

       {

           BankChequeTable BankChequeTable;

           int successCounter = 0;

           int failCounter = 0;

           ttsBegin;

           while select forupdate BankChequeTable

               where

                  (BankChequeTable.RecID == 5637144598)

           {

                   BankChequeTable.ChequeStatus = ChequeStatus::Void;

              if (BankChequeTable.ChequeStatus == ChequeStatus::Cancelled

              || BankChequeTable.ChequeStatus == ChequeStatus::Rejected

              || BankChequeTable.ChequeStatus == ChequeStatus::Void)

             {

              bankChequeTable.voidPositivePay();

             }

                   BankChequeTable.update();

                   successCounter++;

               }

           }

           ttsCommit;

           info(strFmt("%1 records updated successfully.", successCounter));

           info(strFmt("%1 records failed to update.", failCounter));

       }

  • Oceanfish26 Profile Picture
    624 on at

    Thanks for your assistance.

    I don't think this will work in a single-class custom script, though.  Am I wrong?  Can you demonstrate how this will fit into the custom script I provided earlier?

  • SARFARAZ AHMED MUFTI Profile Picture
    32 on at

    Below is the standard code you need to try :

    if (_chequeStatus == ChequeStatus::Cancelled

               || _chequeStatus == ChequeStatus::Rejected

               || _chequeStatus == ChequeStatus::Void)

           {

               bankChequeTable.voidPositivePay();

           }

    The standard method in the table BankChequeTable:

    public static void setChequeStatus(

           CompanyBankAccountId        _accountID,

           BankChequeNum               _chequeNum,

           ChequeStatus                _chequeStatus,

           TransDate                   _transDate,

           Voucher                     _voucher,

           BankChequeRecipientType     _recipientType,

           CompanyId                   _recipientCompany,

           CustVendAC                  _recipientAccountNum,

           CurrencyCode                _currencyCode,

           AmountCur                   _amountCur,

           BankNegInstRecipientName    _recipientName,

           RemittanceAddress           _remittanceAddress = 0,

           RefTableId                  _sourceTableId = 0,

           RefRecId                    _sourceRecId = 0)

       {

           BankChequeTable  bankChequeTable;

           select firstonly forupdate bankChequeTable

               where bankChequeTable.AccountID == _accountID

                   && bankChequeTable.ChequeNum == _chequeNum;

           if (!bankChequeTable)

           {

               throw error(strfmt("@SYS76941", _accountID, _chequeNum));

           }

           bankChequeTable.ChequeStatus                = _chequeStatus;

           bankChequeTable.TransDate                   = _transDate;

           bankChequeTable.Voucher                     = _voucher;

           bankChequeTable.RecipientType               = _recipientType;

           bankChequeTable.RecipientCompany            = _recipientCompany;

           bankChequeTable.RecipientAccountNum         = _recipientAccountNum;

           bankChequeTable.RecipientTransVoucher       = _voucher;

           bankChequeTable.CurrencyCode                = _currencyCode;

           bankChequeTable.AmountCur                   = _amountCur;

           if (_recipientName)

           {

               bankChequeTable.BankNegInstRecipientName = _recipientName;

           }

           if (_remittanceAddress)

           {

               bankChequeTable.RemittanceAddress = _remittanceAddress;

           }

           if (_sourceTableId

               && _sourceRecId)

           {

               bankChequeTable.SourceTableId           = _sourceTableId;

               bankChequeTable.SourceRecId             = _sourceRecId;

           }

           bankChequeTable.BankCurrency = BankAccountTable::find(_accountID).CurrencyCode;

           if (_currencyCode == bankChequeTable.BankCurrency)

           {

               bankChequeTable.BankCurrencyAmount = _amountCur;

           }

           else

           {

               bankChequeTable.BankCurrencyAmount = CurrencyExchangeHelper::curAmount2CurAmount(_amountCur, _currencyCode, bankChequeTable.BankCurrency, bankChequeTable.TransDate);

           }

           if (_chequeStatus == ChequeStatus::Cancelled

               || _chequeStatus == ChequeStatus::Rejected

               || _chequeStatus == ChequeStatus::Void)

           {

               bankChequeTable.voidPositivePay();

           }

           bankChequeTable.update();

       }

  • Oceanfish26 Profile Picture
    624 on at

    internal final class CheckStatusToVoidTest1
    {
        public static void main(args _args)

        {
            BankChequeTable BankChequeTable;
            int successCounter = 0;
            int failCounter = 0;

            ttsBegin;

            while select forupdate BankChequeTable
                where
                   (BankChequeTable.RecID == 5637144598)

            {
                if (BankChequeTable.validateWrite())
                {
                    BankChequeTable.ChequeStatus = 3;
                    BankChequeTable.update();
                    successCounter++;
                }
                else
                {
                    failCounter++;
                }
            }

            ttsCommit;

            info(strFmt("%1 records updated successfully.", successCounter));
            info(strFmt("%1 records failed to update.", failCounter));
        }

    }

  • SARFARAZ AHMED MUFTI Profile Picture
    32 on at

    Hi,

    Can you please share the code where you can update the table?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 843 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 405 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 322 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans