API
Version 7.x > API > Custom workflow action View modes: 
User avatar
Certified Developer v7
Certified  Developer v7
emanuele.firmani-aduno-gruppe - 3/5/2013 3:05:33 AM
   
Custom workflow action
I'm creating a custom workflow action that I'll use when a form is submitted.
The form creates/updates the contact after submission.

How can I retrieve the current contact infos and custom properties from the code I wrote for such action?

Thanks
Regards
Emanuele Firmani

User avatar
Certified Developer v7
Certified  Developer v7
emanuele.firmani-aduno-gruppe - 3/12/2013 9:23:12 AM
   
RE:Custom workflow action
I'm using now the following piece of code:
var contact = OnlineMarketingContext.GetCurrentContact();

The problem I'm facing is: when I let the scheduled task "Process activities log" to run automatically, the code works; if I run the task manually, the variable contact contains the user I'm using to run it (Global administrator).
More or less, it's the same behavior I get when I move the Automation Process to a given action block manually (it loses the real current contact, returning the logged user).

How can I solve it?

Regards
Emanuele Firmani

User avatar
Kentico Support
Kentico Support
kentico_radekm - 3/14/2013 4:26:26 AM
   
RE:Custom workflow action
Hello.

As we discussed in e-mails, in this scenario the GetCurrentContact method will not work, as it is not called in visitor context. You would need to get visitor contact when submitting the form, e.g. using some On-line form event, like OnAfterSave, pass it to your custom code (custom action) and process it within, instead of calling GetCurrentContact in your custom code.

Best Regards,
Radek Macalik