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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Error: Cannot create a record in Balance (CustVendTmpOpenTransBalances). Currency: , 0,00.The record already exists

(0) ShareShare
ReportReport
Posted on by 630

Hi,

This is the error we got from the AP module.

This error only occurs when a specific Vendor is being used. There are no duplicate records in the table VendTransOpen and it is very unlikely that a recodid from VendOpentrans is being inserted twice into CustVendTmpOpenTransBalances because the process works fine when using other Vendor Accounts.

 

Can you guys give me some insights on how to solve this?

Thanks! :)

 

 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Einar Lárusson Profile Picture
    105 on at

    In the add method of the class CustVendOpenTransBalancesManager i added this code

    if (tmpBalances.TransOpenRecId)

           tmpBalances.insert();

    The system was trying to add a record to the t,p tabel with the TransOpenRecId = 0.

    Why that happens i don't know but i am trying to figure that out, but this is a temp solution so that it is possible to open the form at least

    Hope this helps

    Einar

    epexplorer.blogspot.com

  • Community Member Profile Picture
    on at

    Hi Einar,

       We inserted the code in classes\CustVendOpenTransBalancesManager\add but the same error coming out, in addition to this the debugger coming out without any breakpoints set. The debugger pointing on classes\CustVendOpenTransBalancesManager\add   Debug::assert(_transExchRate != 0);

  • Suggested answer
    Einar Lárusson Profile Picture
    105 on at

    Hi

    Then you should put the if statement around the whole code block, then nothing is done in case of there is no record to insert into the tmp tabel.

    Let me know how that works

    Regards

    Einar

  • Community Member Profile Picture
    on at

    I try to insert the code,if statement in the whole block of codes but the same error is coming out..The debugger is pointing in every related codes that has a Debug::assert(_transExchRate != 0);..

  • Suggested answer
    Einar Lárusson Profile Picture
    105 on at

    Hi

    Then you are not haveing the exact same problem as we had. We had a problem that the system was trying to insert revords with 0 as the transrecid and we got the error the second time the system tryed to insert a record with transrecid = 0.

    This offcourse breaks the unique index on the table and we get the error that the record allready exists.

    You problably need to do a check on the transExchRate since that is what is causing the debugger to dtop.

    Regards

    Einar

  • Suggested answer
    Community Member Profile Picture
    on at

    May i know how did you fixed your error?Just for reference.

    Einar,

     The form is temporarily OK without an error. what I did is, I comment out the code: and add your suggested code.

    /*

       // Assert that the exchange rate values passed in are not zero as they may be used in calculations as divisors

       Debug::assert(_transExchRate != 0);

       Debug::assert(_transToMstExchRate != 0);

       Debug::assert(_transMstToDisplayMstExchRate != 0);

       Debug::assert(_mstToDisplayExchRate != 0);

       tmpBalances.TransCompany = _transCompany;

       tmpBalances.TransOpenRecId = _transOpenRecId;

       tmpBalances.TransAmount = _transAmount;

       tmpBalances.EstimatedCashDiscAmount = _estimatedCashDiscAmount;

       tmpBalances.TransCurrency = _transCurrency;

       tmpBalances.TransDate = _transDate;

       tmpBalances.TransExchRate = _transExchRate;

       tmpBalances.TransToMstExchRate = _transToMstExchRate;

       tmpBalances.TransMstToDisplayMstExchRate = _transMstToDisplayMstExchRate;

       tmpBalances.MstToDisplayExchRate = _mstToDisplayExchRate;

       tmpBalances = this.calculateBalances(tmpBalances);

       tmpBalances.insert(); */

       if (tmpBalances.TransOpenRecId)

          tmpBalances.insert();

  • Suggested answer
    Einar Lárusson Profile Picture
    105 on at

    Hi

    The only thing that i did was to add the if statement like this

    if (tmpBalances.TransOpenRecId)

         tmpBalances.insert();

    Then the system is not inserting empty records which was the root for our problem => the system tried to insert two records with the TransOpenRecId = 0.

    If you comment out the code like you do then you will not get anything in the tmp table.

    This is how the code looks like

      // Assert that the exchange rate values passed in are not zero as they may be used in calculations as divisors

      Debug::assert(_transExchRate != 0);

      Debug::assert(_transToMstExchRate != 0);

      Debug::assert(_transMstToDisplayMstExchRate != 0);

      Debug::assert(_mstToDisplayExchRate != 0);

      tmpBalances.TransCompany = _transCompany;

      tmpBalances.TransOpenRecId = _transOpenRecId;

      tmpBalances.TransAmount = _transAmount;

      tmpBalances.EstimatedCashDiscAmount = _estimatedCashDiscAmount;

      tmpBalances.TransCurrency = _transCurrency;

      tmpBalances.TransDate = _transDate;

      tmpBalances.TransExchRate = _transExchRate;

      tmpBalances.TransToMstExchRate = _transToMstExchRate;

      tmpBalances.TransMstToDisplayMstExchRate = _transMstToDisplayMstExchRate;

      tmpBalances.MstToDisplayExchRate = _mstToDisplayExchRate;

      tmpBalances = this.calculateBalances(tmpBalances);

      if (tmpBalances.TransOpenRecId)

         tmpBalances.insert();

    Regards

    Einar

  • Community Member Profile Picture
    on at

    Hi,

      Thanks for the help Einar, Its now working.

  • Suggested answer
    Community Member Profile Picture
    on at

    You most likely have data damage (Orphaned records) in the specTrans table.

    you can check it with this small job below...:

    ___________________

    static void Check_Orphans_Spectrans(Args _args)
    {
        SpecTrans       specTrans;
        CustTransOpen   custTransOpen;
        counter         i;
        ;

        while select forupdate * from SPECTRANS where SpecTrans.RefTableId == 865 // 866 for Debtors
        {
            select firstonly * from CustTransOpen where CustTransOpen.RecId == SpecTrans.RefRecId;

            if(!CustTransOpen.RecId)
            {
                info(strFmt("%1 balance : %2",SpecTrans.RefRecId,SpecTrans.Balance01));
                //SpecTrans.delete();
                i++;
            }
        }
        info(strFmt("records deleted : %1",i));
    }

    ___________________

    If you find records it means they don't have a corresponding Vend/CustTransOpen record which should be impossible!!

    You can delete the specTrans records that meet this criteria as the specTrans table holds the settling flag between invoice and payment pre-posting. If you delete the SpecTrans record you lose the marking, which you can complete again. If you find records that meet the criteria from the job it showing there is marking but they are marked to nothing so they need to be removed.

    You can remove the records you found by un-commenting the //SpecTrans.delete() line in the job...

     

  • trond Profile Picture
    on at

    Rynharth, did every user experience this on the specific vendor?

    We've got the same issue with a vendor record, but not with every user.

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

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans