We have a client requirement like this:
There are some running nintex workflows on a list. We have made some changes to the existing workflow through code. The updated workflow is to be started automatically by terminating the existing workflows and updating required fields. We have successfully written a tool that accomplishes the tasks properly.
There is one issue though, we are unable to set the “workflow initiator” to the original. Since the code runs under system account, the initiator is “system account”, whereas we need it to be set with the name of the user who originally started the workflow.
There is a “read only” property of “SPWorkflowAssociation” class named author that provides the initiator id. But we are unable to find a way to set the initiator on starting the new workflow.
Solution :
The only supported way you may be able to do this is to start the workflow in the context of the correct user.
To do this, use the SPSite constructor that take an SPUserToken object. You would need to determine the initiator of the old workflow and use this as the SPUserToken to run the code as this user when you start the new workflow.