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)

Vendor Creation Error through X++

(0) ShareShare
ReportReport
Posted on by

Vendor-Insert-Error.PNG

When I try to create a new Vendor getting error like

'Cannot create a record in Vendors (VendTable). Vendor account: **** , **** The record already exists.'

There is no such vendor in Vendor Table and I checked NextVal from SystemSequences Table where NextVal is greater than Max(RecId) of VendTable.

Please help me to solve this issue.

Please Find the attachment for reference.

Any suggestion will be greatly appreciated.

Regards,

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    axk Profile Picture
    925 on at

    Hello,

    Are you sure that you are inserting vendor with unique AccountNum? 

    VendTable does not allow duplicates on AccountNum and Party. Maybe you should check which one is causing an error.

  • Community Member Profile Picture
    on at

    Hi,

        yes i am sure that AccountNum is unique and PartyId number sequence is not duplicating.

  • André Arnaud de Calavon Profile Picture
    300,924 Super User 2025 Season 2 on at

    Hi Chandan,

    Can you review all indexes on the VendTable table to see if there is a customization if there are more indexes set to not allow duplicates? Have you actually used the debugger to find out if the AccountNum and Party do get values which are not used before?

    If this is not helping, can you share your coding, so we can help you reviewing this?

  • Community Member Profile Picture
    on at

    Hi,

    I have debugged the code and checked whether  PartyID is duplicating or not but it is not used before... There is no customization on VendTable indexes.

    This is my code:

    if(ledgerJournalTransfromSSAS.AccountType == LedgerJournalACType::Vend)

           {

               checkrecord               = vendTable::exist(ledgerJournalTransfromSSAS.AccountNum);

               if(checkrecord == false)

               {

                   ttsbegin;

                   vendTable.clear();

                   vendTable.AccountNum    = ledgerJournalTransfromSSAS.AccountNum;

                   vendTable.Name          = ledgerJournalTransfromSSAS.CustName;

                   vendTable.VendGroup     = ledgerJournalTransfromSSAS.CustGroupId;

                   vendTable.Currency      = ledgerJournalTransfromSSAS.CurrencyCode;

                   vendTable.LanguageId    = 'en-in';

                   vendTable.PartyType     = DirPartyType::Person;

                   vendTable.insert();

                   ttscommit;

               }

           }

  • André Arnaud de Calavon Profile Picture
    300,924 Super User 2025 Season 2 on at

    Assuming the correct value is passed with the AccountNum field in ledgerJournalTransfromSSAS your code should work.

    There is only one thing to know. If you aren't providing a Party reference, the insert logic will overwrite the party type. So it would be better to use the next line in addition (after filling PartyType and before insert:

    vendTable.Party = DirPartyTable::createNew(vendTable.partyType, '').RecId;

  • Community Member Profile Picture
    on at

    Hi,

    I tried the code for Party field still its showing same error...I  tried the same logic in test company, Record is inserting in Vendor Table but in Live company its  not happening. And also  I tried by updating "SystemSequences.NextVal = Max(RecID) from VendTable + 1"  and written a test job to insert Test Data but same error.

  • André Arnaud de Calavon Profile Picture
    300,924 Super User 2025 Season 2 on at

    So the error resides on the production environment only? It would be recommended to create a copy of this instance and start debugging to find out what is really causing the problem. It really should be a duplicate value. Or you didn't provide all information and the code is within a loop where it tries to loop multiple records with the same new vendor.

    The code suggestion was not solving the insert error, but is solving the issue on party type if the GAB parameters has Organization as party type for new vendors.

  • Community Member Profile Picture
    on at

    Hi,

    But one change i tried to make is by disabling the PartyID index of VendTable then Insertion is happening but when i debugged the code i.e., DirPartyTable-> GetNewPartyId the PartyID is generating as per Next value of NumberSequence which is not exist in VendTable.

  • Verified answer
    André Arnaud de Calavon Profile Picture
    300,924 Super User 2025 Season 2 on at

    The index should never be disabled. Do you have a certain loop where multiple vendor inserts could be the reason? Can you also check if the party number sequence is set to be NOT continuous? SQL server is not lying. There should be a duplicate.

  • Community Member Profile Picture
    on at

    No what code i have sent is the only loop where new vendor will be inserted. PartyId number sequence is set to Not Continuous.

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
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Scott_itD Profile Picture

Scott_itD 2 Community Manager

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans