As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
<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> …
Hi Nico O _
Were you able to solve this issue? Facing a similar situation here.
Cheers !!!
Hiten Rastogi
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.
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.
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