I have a CRM entity event in my workflow, that creates an incident in our CRM system. Is it possible to impersonate the user who starts the workflow as the created by in CRM, instead of the K2 system user?
As you are aware the workflow will execute any smartobject methods as the service account. You can change the execution account for an event, but you must hard code an account and password, which doesn't help you.
The only way I can think to do this would be to write some custom code (using the K2 Default Server Event (code) event) that calls the CRM smartobject using impersonation. You will need to understand the SmartObject API and work out how to impersonate the workflow originator.
Please find my comment . you can not execure CRM entity smart object in impersonated user context in process , process always run in k2_service account context so whenever in process any smart object exection will be there so created or update by will be as k2 service account . but if same impersonaetd smart object will run from smart froms then user details will be there . so there is some workarounf you can do as below .
THis is a approach where you can track the user details .