01-15-2016 05:50 AM
<serviceTask id="alfrescoScripttask1" name="add tag" activiti:class="org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate">
<extensionElements>
<activiti:field name="script">
<activiti:string><![CDATA[if(bpm_package && bpm_package.children){ for (var i = 0; i < bpm_package.children.length; i++) { bpm_package.children.addTag("Some tag"); }}]]></activiti:string>
</activiti:field>
</extensionElements>
</serviceTask>
…
<activiti:field name="runAs">
<activiti:string><![CDATA[admin]]></activiti:string>
</activiti:field>
…
02-15-2019 01:59 AM
Hi Nico O _
Were you able to solve this issue? Facing a similar situation here.
Cheers !!!
Hiten Rastogi
02-15-2019 04:04 AM
The only way to deal with this would require you to use an expression instead of a hard-coded user ID. The expression would have to make use of some Java class / code to dynamically determine the correct user name. The Java class org.alfresco.repo.tenant.TenantUtil is typically used to execute code as a specific user in a specific tenant, while the org.alfresco.repo.tenant.TenantService interface provides utilities to translate abstract identifiers (including user names) to tenant specific identifiers.
02-18-2019 05:31 AM
Hi Axel,
As per your suggestion, I inserted an executionListener in the startEvent of the workflow as below
<startEvent id="startevent1" name="Start" activiti:formKey="scwf:submitReviewTask">
<extensionElements>
<activiti:executionListener event="end" class="com.xyz.abc.workflow.SetAdminUser" />
</extensionElements>
</startEvent>
In the SetAdminUser class, in the end, I set the userName in an execution variable as below.
execution.setVariable("admin", "admin"+SEPARATOR+tenantDomain);
and now I am trying to use this username in my runAs field in one of my serviceTask as below
<activiti:field name="runAs">
<activiti:string>
<![CDATA[execution.getVariable("admin")]]>
</activiti:string>
</activiti:field>
but the expression isn't resolving and is taken as it is. Hence the below error.
2019-02-18 15:14:16,224 DEBUG [jscript.RhinoScriptProcessor.calls] [http-bio-8080-exec-2] workspace://SpacesStore/486e54d2-0947-4984-b12b-453b8f88609e Exception
org.mozilla.javascript.WrappedException: Wrapped org.alfresco.service.cmr.workflow.WorkflowException: 01180026 runas user 'execution.getVariable("admin");' does not exist. (workspace://SpacesStore/486e54d2-0947-4984-b12b-453b8f88609e#12)
Any help would be great here.
Cheers !!!
02-18-2019 06:32 AM
To answer the above reply I posted we just have to replace the below code in bpmn
<activiti:field name="runAs">
<activiti:string>
<![CDATA[execution.getVariable("admin")]]>
</activiti:string>
</activiti:field>
with
<activiti:field name="runAs">
<activiti:expression>${execution.getVariable("admin")}</activiti:expression>
</activiti:field>
OR(make it less verbose)
<activiti:field name="runAs" expression="${execution.getVariable('admin')}" />
Reference: https://www.activiti.org/userguide/#serviceTaskFieldInjection
Cheers !!!
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.