ulisses
ulisses

Reputation: 1581

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!

Upvotes: 2

Views: 3942

Answers (2)

Geoffrey DELMEE
Geoffrey DELMEE

Reputation: 782

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.

Upvotes: 2

ztirom
ztirom

Reputation: 4438

Just try the AxDirPartyTable Class like:

AxDirPartyTable       axDirPartyTable;

axDirPartyTable = AxDirPartyTable::construct();
axDirPartyTable.parmName(myName);
axDirPartyTable.parmPartyNumber(myPartyNumber);
axDirPartyTable.save();

Examples could be found here: How to create a record in Global address book throgh code.

Upvotes: 1

Related Questions