cancel
Showing results for 
Search instead for 
Did you mean: 

Run Activiti Script As System in Alfresco 5.0

tonyrivet
Champ in-the-making
Champ in-the-making
Hi,

I wanted to run a JS script in an Activiti workflow as the System user.
I did that many times in v4.2, setting "System" in the "runas" field of an AlfrescoScriptTask, but when running this in v5.0 (Enterprise) the following error shows up : "runas user 'System' does not exist".

It seems the way the System user is created in Alfresco 5.0 has changed because I can't find it in the people container anymore. The thing is the ActivitiScriptBase uses the personService to check if the "runas" user exists and looks through the people container to do so.

So here are my two questions :
- is anybody aware of a new way to handle the System user in v5.0 (I didn't find any info to confirm that…) ?
- how can I run a Script in Activiti as the System user now ?

Thanks !
2 REPLIES 2

afaust
Legendary Innovator
Legendary Innovator
Hello,

as far as I can see, no user called "System" ever existed in any of my Repositories - no matter the Alfresco version (currently checked a 4.2.4). I must admit, I have never used the "runAs" configuration on AlfrescoScriptTask - whenever I want to execute something as the System user, I use a Java delegate and do a proper AuthenticationUtil.runAsSystem().
So far, I can see no change concerning the "System" user behaviour in Alfresco 5.0

Regards
Axel

tonyrivet
Champ in-the-making
Champ in-the-making
Hi, thanks for your response !

I checked on a native 4.2 environment and you're right, the System user does not exist in the people container neither.
It existed on my "customized" 4.2 environment, but must have been created automatically I don't really know how…

So basically, I assume that it is not possible to run a ScriptTask as System ??

I agree I could use Java Delegates (and I do for some complex tasks) but my process contains many simple pieces of logic and I find it a bit heavy to create a dedicated Delegate for each.
I think I will customize the AlfrescoScriptTask and override the executeScript() method to handle the System user properly.