janev
Novice

Impersonate user in CRM

Hello,

 

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?

 

 

0 Kudos
Reply
4 Replies
Andrew_Blinco
Apprentice

Re: Impersonate user in CRM

Hi janev

 

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.

0 Kudos
Reply
K2Expert1
Apprentice

Re: Impersonate user in CRM

Hi Janev,

 

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 .

  •  Create a custom field like "ActionedUser" in CRM entity 
  • Get the user domain id and call user smart object to get the user GUID
  • On each action try to get user details from k2 form 
  • At time of CRM smart object execution pass the user GUID 

THis is a approach where you can track the user details .

 

- Arvind

Reply
janev
Novice

Re: Impersonate user in CRM

Thanks guys,

Arvind, your approach is the one I've been using so far, but I thought I´d check here if any ,,cleaner'' solution was available. 

0 Kudos
Reply
K2Expert1
Apprentice

Re: Impersonate user in CRM

Great janev :)
0 Kudos
Reply