cancel
Showing results for 
Search instead for 
Did you mean: 

Get last ID of objects

Former Member
0 Kudos

Hi all,

I'd like to know if there is a way to get the ID given to the object saved.

For example, if I save a new Employee, I'd like to get its EmployeeID number.

After I add it (MyEmployeeInfoObject.add) the value MyEmployeeInfoObject.EmployeeID = 0, and not the ID given by Business One.

I know I can find it it the ONNM table, but I can't be sure the EmployeeID retrieve from this table is the one used to add the employee as an other user can add an employee at the same time. I also know that I have to remove 1 to this number because it's the next one available.

That problem is not only for the EmployeeInfo object...

Is there a SQL Server like function "SELECT @@IDENTITY"

Thanks for your help.

Sébastien

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

After you create an object you can call the oCompany.GetNewObjectCode(ByRef ObjectCode As String) to get the last code of that object:

for example:

...

MyEmployeeInfoObject.add()

Dim strCode As String

strCode = oCompany .GetNewObjectCode(strCode)

MsgBox ("New Object Code = " + strCode)

Ribeiro Santos

Former Member
0 Kudos

Thanks a lot Ribeiro

I didn't know this function.

Answers (0)