<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to change who started a process? in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/how-to-change-who-started-a-process/m-p/29578#M12588</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looks like what I'm trying to do is not possible:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://github.com/Activiti/Activiti/blob/master/modules/activiti-engine/src/main/resources/org/activiti/db/mapping/entity/HistoricProcessInstance.xml#L131" title="https://github.com/Activiti/Activiti/blob/master/modules/activiti-engine/src/main/resources/org/activiti/db/mapping/entity/HistoricProcessInstance.xml#L131" rel="nofollow noopener noreferrer"&gt;Activiti/HistoricProcessInstance.xml at master · Activiti/Activiti · GitHub&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The update statement gets executed, but start_user_id is not part of the fields that get set&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 May 2017 20:08:43 GMT</pubDate>
    <dc:creator>james_kleeh</dc:creator>
    <dc:date>2017-05-09T20:08:43Z</dc:date>
    <item>
      <title>How to change who started a process?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-change-who-started-a-process/m-p/29575#M12585</link>
      <description>Currently when I'm starting a process, I set the authenticatedUserId through the identity service. I would like to change who started a project (transfer ownership functionality). I have changed the identity links, however when querying process instances with `.startedBy()`, it still shows the old u</description>
      <pubDate>Mon, 08 May 2017 19:26:36 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-change-who-started-a-process/m-p/29575#M12585</guid>
      <dc:creator>james_kleeh</dc:creator>
      <dc:date>2017-05-08T19:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to change who started a process?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-change-who-started-a-process/m-p/29576#M12586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perhaps,there is no public API for your use case.&lt;/P&gt;&lt;P&gt;You need to&amp;nbsp;use dao directly as follows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN&gt;Context.getCommandContext()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;.getHistoricProcessInstanceEntityManager()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;.findHistoricProcessInstance(%ProcessInstanceId%)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;.setStartUserId(%UserId%);&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 May 2017 04:20:19 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-change-who-started-a-process/m-p/29576#M12586</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-05-09T04:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to change who started a process?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-change-who-started-a-process/m-p/29577#M12587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In my case&amp;nbsp;Context.getCommandContext() is returning null. Any idea why?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="color: #a9b7c6; background-color: #2b2b2b; font-size: 9.0pt;"&gt;&lt;SPAN style="color: #9876aa;"&gt;processEngineConfiguration&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;commandExecutor&lt;/SPAN&gt;.execute(&lt;SPAN style="color: #cc7832;"&gt;new &lt;/SPAN&gt;Command&amp;lt;Object&amp;gt;() {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Object execute(CommandContext commandContext) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commandContext&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;SPAN style="color: #9876aa;"&gt;getHistoricProcessInstanceEntityManager&lt;/SPAN&gt;()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .findHistoricProcessInstance(id)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;SPAN style="color: #9876aa;"&gt;setStartUserId&lt;/SPAN&gt;(&lt;SPAN style="color: #9876aa;"&gt;username&lt;/SPAN&gt;)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;})&lt;/PRE&gt;&lt;P&gt;and it doesn't fail, however the change doesn't take effect&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've also tried the following&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="color: #a9b7c6; background-color: #2b2b2b; font-size: 9.0pt;"&gt;&lt;SPAN style="color: #9876aa;"&gt;processEngineConfiguration&lt;/SPAN&gt;.&lt;SPAN style="color: #9876aa;"&gt;commandExecutor&lt;/SPAN&gt;.execute(&lt;SPAN style="color: #cc7832;"&gt;new &lt;/SPAN&gt;Command&amp;lt;HistoricProcessInstance&amp;gt;() {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HistoricProcessInstance execute(CommandContext commandContext) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HistoricProcessInstanceEntityManager manager = commandContext.&lt;SPAN style="color: #9876aa;"&gt;getHistoricProcessInstanceEntityManager&lt;/SPAN&gt;()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HistoricProcessInstance instance = manager.findHistoricProcessInstance(&lt;SPAN style="color: #9876aa;"&gt;id&lt;/SPAN&gt;)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; instance.&lt;SPAN style="color: #9876aa;"&gt;setStartUserId&lt;/SPAN&gt;(&lt;SPAN style="color: #9876aa;"&gt;username&lt;/SPAN&gt;)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commandContext.&lt;SPAN style="color: #9876aa;"&gt;dbSqlSession&lt;/SPAN&gt;.update(instance)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; instance&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;})&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 May 2017 18:53:02 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-change-who-started-a-process/m-p/29577#M12587</guid>
      <dc:creator>james_kleeh</dc:creator>
      <dc:date>2017-05-09T18:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to change who started a process?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-change-who-started-a-process/m-p/29578#M12588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looks like what I'm trying to do is not possible:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://github.com/Activiti/Activiti/blob/master/modules/activiti-engine/src/main/resources/org/activiti/db/mapping/entity/HistoricProcessInstance.xml#L131" title="https://github.com/Activiti/Activiti/blob/master/modules/activiti-engine/src/main/resources/org/activiti/db/mapping/entity/HistoricProcessInstance.xml#L131" rel="nofollow noopener noreferrer"&gt;Activiti/HistoricProcessInstance.xml at master · Activiti/Activiti · GitHub&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The update statement gets executed, but start_user_id is not part of the fields that get set&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 May 2017 20:08:43 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-change-who-started-a-process/m-p/29578#M12588</guid>
      <dc:creator>james_kleeh</dc:creator>
      <dc:date>2017-05-09T20:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to change who started a process?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-change-who-started-a-process/m-p/29579#M12589</link>
      <description>&lt;P&gt;Have you found an answer? I have the same issue.&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jul 2021 10:34:40 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-change-who-started-a-process/m-p/29579#M12589</guid>
      <dc:creator>Fjordo</dc:creator>
      <dc:date>2021-07-19T10:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to change who started a process?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-change-who-started-a-process/m-p/29580#M12590</link>
      <description>&lt;P&gt;This worked correctly to me, I made an execution listener on the "start" of the Start Task and here is the code&lt;/P&gt;&lt;PRE&gt;public class SetAuthorAsWFInitiator implements ExecutionListener {

	private static final long serialVersionUID = 1095132995665073418L;

	@Override
	public void notify(DelegateExecution execution) throws Exception {
		AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork&amp;lt;Object&amp;gt;() {

			@Override
			public Object doWork() throws Exception {
				
				ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
				Map&amp;lt;Object, Object&amp;gt; registeredBeans = processEngineConfiguration.getBeans();
				ServiceRegistry serviceRegistry = (ServiceRegistry) registeredBeans.get(ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
				NodeService nodeService = serviceRegistry.getNodeService();
				ActivitiScriptNode bpm_package = (ActivitiScriptNode) execution.getVariable("bpm_package");
				List&amp;lt;ChildAssociationRef&amp;gt; childAssocs = nodeService.getChildAssocs(bpm_package.getNodeRef());
				NodeRef documentNode = childAssocs.get(0).getChildRef();
				
				List&amp;lt;AssociationRef&amp;gt; targetAssocs = nodeService.getTargetAssocs(documentNode, Constants.AUTHOR_ASSOC);
				NodeRef creatorNodeRef = targetAssocs.get(0).getTargetRef();
				NodeRef creatorHomeFolderNodeRef = (NodeRef) nodeService.getProperty(creatorNodeRef, ContentModel.PROP_HOMEFOLDER);

				execution.setVariable("initiator", new ActivitiScriptNode(creatorNodeRef, serviceRegistry));
				execution.setVariable("initiatorhome", new ActivitiScriptNode(creatorHomeFolderNodeRef, serviceRegistry));
				
				processEngineConfiguration.getCommandExecutor().execute(new Command&amp;lt;Object&amp;gt;() {
				    public Object execute(CommandContext commandContext) {
				        commandContext
				            .getHistoricProcessInstanceEntityManager()
				            .findHistoricProcessInstance(execution.getProcessInstanceId())
				            .setStartUserId((String) nodeService.getProperty(creatorNodeRef, ContentModel.PROP_USERNAME));
						return commandContext;
				    }
				});
				
				
				return null;
			}

		}, AuthenticationUtil.getAdminUserName());
	}
}&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Jul 2021 10:47:37 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-change-who-started-a-process/m-p/29580#M12590</guid>
      <dc:creator>Fjordo</dc:creator>
      <dc:date>2021-07-19T10:47:37Z</dc:date>
    </item>
  </channel>
</rss>

