Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

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

(0) ShareShare
ReportReport
Posted on by 568

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? 

  • Oceanfish26 Profile Picture
    Oceanfish26 568 on at
    RE: Am I able to update table BANKCHEQUETABLE using a custom script?

    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
    Oceanfish26 568 on at
    RE: Am I able to update table BANKCHEQUETABLE using a custom script?

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

  • Suggested answer
    RE: Am I able to update table BANKCHEQUETABLE using a custom script?

    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
    Oceanfish26 568 on at
    RE: Am I able to update table BANKCHEQUETABLE using a custom script?

    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?

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

    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
    Oceanfish26 568 on at
    RE: Am I able to update table BANKCHEQUETABLE using a custom script?

    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));
        }

    }

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

    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

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,703 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,433 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans