0

I have a public facing site with a "Contact Us" SharePoint list. Users are able to submit a new request through a custom Web Part which creates a SP List item using server side code.

After the list item is created, a SP Designer workflow is triggered and sends an email to the appropriate users.

In order to create the list item when there's no user logged in, I had to run the snippet with Elevated Privileges. Therefore, the SP List item is created under "System Account" and this is why I assume the workflow never starts.

  1. Should I impersonate a specific user in my server side code when creating the item?
  2. Should I send the email using code instead of using a SP Designer Workflow?

Any help would be greatly appreciated

3
  • 1
    I would impersonate a specific "workflow" user to handle the workflow logic, also I'd let the SPD workflow handle the email for quick access to changes.
    – Mike
    Commented Mar 16, 2015 at 14:21
  • @Mike Thanks for the prompt reply. I assume you mean creating the list item as a specific user, right? Or do you mean adding an impersonation step to the workflow? I doubt this second option would work since the workflow is not even started. Thank you!
    – Gonzalo
    Commented Mar 16, 2015 at 14:26
  • i meant creating the item as a specific user, yes.
    – Mike
    Commented Mar 16, 2015 at 18:42

1 Answer 1

0

Either option would work, but since you are doing it server side already, I'd handle the emailing from there as well.

If you want to give users the ability to change up the SPD workflow at any point, then impersonating a created by user would be better so you don't have to redeploy changes.

I guess it boils down to developer convenience vs end user customization.

1
  • Yes, in my case users need the ability to change the email template. I could have used a Property Bag for this, but I ended up impersonating a specific user. Thank you.
    – Gonzalo
    Commented Mar 16, 2015 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.