Obtaining IDs for new records

 

How new items are given ID’s, and how the programmer can programmatically obtain those ID’s.

 

When a new item (or multiple items) are inserted into the database through the API a structure of XML is returned that allows you to retrieve IDs of newly inserted items. e.g. a xml structure returned from an employee save may look like this:

 

<EMPLOYEES>

<INSERTED>

<ID>1200

<NOTES>

<INSERTED>

<ID>125</ID>

</INSERTED>

<UPDATED/>

</NOTES>

</INSERTED>

<UPDATED>

<ID>101</ID>

</UPDATED>

</EMPLOYEES>

 

For all items that are saved into individual tables that later require an ID to reference them, the ID will be included in the xml structure. IDs are returned in the order they were specified to be saved in. (e.g. if you have 4 employees to insert, the 4 IDs returned will be in the order you specified the employees to be inserted originally).