Get current identifier

Get current identifier

  
Hello Everybody,
I just inserted a record into table in a SAVE process.  But in that same SAVE process, I want to update that record later in the process.  How do I get the record identifier of that recently inserted record to make the update work?  In SQL, there is an @IDENTITY command that gets the most recent record identifier .  Is there some built in command in Outsystems?
Thanks in advance, Frank
Hi Frank,

When using a entity action to do the inserts (Create<entity> or CreateOrUpdate<entity>) those can be get as the return of the method.

On Advanced query inserts its a bit tricky.
Note: I didn't test this but should work

Create a stucture in your eSpace with just one Attribute with type "<YourEntityName> Indentifier"
Set that structure as your Output Structure.
After your Insert, add a "Select SCOPE_IDENTITY()"

That should do it.

Also note that I said SCOPE_IDENTITY() instead of @@IDENTITY like you sugested. That is because of possible triggers that you could eventually have on your entity interfering with that variable.


Regards,
João Rosado