Search code examples
axaptadynamics-ax-2012x++sequences

Create a record on DirPartyTable from code?


I have to create a new record on DirPartyTable . I used this code:

DirPartyTable _myDirPartyTable;
myPartyNumber = DirPartyTable::getNewPartyNumber((webSession() == null));
myDirPartyTable = DirPartyTable::createNew(myPartyType , myName, myPartyNumber);

// or without partynumber

myDirPartyTable = DirPartyTable::createNew(myPartyType , myName);

But in both cases the standard method generate two Sequence ParyNumber. In Debu mode I saw the system get two times the PartyNumber .

How can I create a record without creating holes in the sequence numeric?

I tried to use this another code:

select forupdate myDirPartyTable;
myDirPartyTable.name = ....;
//etc
myDirPartyTable.insert();

But does not create the record.

Thanks, enjoy!


Solution

  • DirPartytable is the basis table of address book framework and is the top level of table inheritance hierarchy see references in Implementing the Global Address Book Framework (White paper)

    You shouldn't try to directly create a party but create from your entity which implement the DirParty framework. When you create a vendor, you don't create a DirParty (with herited tables) and then create a VendTable and link them all together. Creating a vendor will do it directly.

    Then, if you still encounter two times Party number calls, log a case at Microsoft support.

    ulisses: I solved problem, I have to create before the PartyType (Organization or Person etc...)and after update my created DirPartyTable.