Skip to content


Identity Column

Michael Markovich asked 6 years ago
We’re implementing integration of e-commerce web app based on Microsoft E-Commerce server with Microsoft CRM. The concern was raised on how SmartConnect handles new value of identity column as it is creating a trigger on the source table. I’m referring here to the @@identity and @@scope_identity issue in MSSQL Server
Patrick Roth Staff answered 6 years ago
” creating a trigger on the source table”
SmartConnect does not create a SQL trigger on the source CRM table.
Instead, SmartConnect registers a plug-in entity event with the CRM SDK.  However CRM handles that event is what it is. 
When CRM saves a record, it fires the event in question and passes the data from that record inserted/changed into the plugin which then passes the data from it to the eOne web service.
Because of this, @@identity or @@scope_identity don’t come into play at all.
Michael Markovich replied 6 years ago


Thanks for a quick reply. To clarify, the “source” here is our e-commerce based system, CRM is destination and is not a concern. We have implemented another integration with CRM using SmartConnect where the “source” is in-house SQL Server database, and verified that triggers were created and it had an impact behavior of @@identity variable. We were able to come up with a work around, however, with E-Commerce server we might be quite limited.

Patrick Roth Staff replied 6 years ago

I’m going to stick with my original answer.
For change or realtime events, SmartConnect registers an event on the event in MS CRM using the CRM SDK. the event fires the SC plugin that is registered and passes it the entity/data to be parsed.

If CRM is passing in the wrong data to the plugin due to @@identity/@@scope_identity, there isn’t anything the SmartConnect can do about it or even kno w that occurred.

Michael Markovich replied 6 years ago

Thanks, but it does not address my concern on “source” tables in our in-house SQL Server and has nothing to do with CRM.

Patrick Roth Staff replied 6 years ago

As you made it a point of mentioning CRM, I had assumed you meant a CRM trigger instead of a SQL db trigger.

If you can examine the SQL db trigger that is created on the table, for both realtime or change triggers, we can see that in both cases that SQL passes us the “INSERTED” table that the trigger table would then either log into a tracking table or calling the eone web service. If there is an identity column in that table – it would be passed into the proc as the INSERTED record and we’d use whatever that values is (if needed because it was a key) wherever it came from.

So SC doesn’t look at @@identity or @@scope_identity directly either way.

If you would like to submit an answer or comment, please sign in to the eOne portal.