Skip to Content
author's profile photo Former Member
Former Member

Get last ID of objects

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.


Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 17, 2005 at 04:36 PM

    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:



    Dim strCode As String

    strCode = oCompany .GetNewObjectCode(strCode)

    MsgBox ("New Object Code = " + strCode)

    Ribeiro Santos

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.