Script Task: Using external files as source

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2013 01:44 AM
Hey,
in my currrent project i'm using the script task quite heavily. The script task is mainly used to config my processes, e.g. init process variables like e-mail recipients. I would like to store the script source on the file system, instead of the process definition. The reason therefore is, that even adding another recipient to a process variable (e.g."a@b.com" to "a@b.com,c@d.com"), I must deploy the process again.
Is there any (simple) way to do this?
Cheers
Malte
in my currrent project i'm using the script task quite heavily. The script task is mainly used to config my processes, e.g. init process variables like e-mail recipients. I would like to store the script source on the file system, instead of the process definition. The reason therefore is, that even adding another recipient to a process variable (e.g."a@b.com" to "a@b.com,c@d.com"), I must deploy the process again.
Is there any (simple) way to do this?
Cheers
Malte
Labels:
- Labels:
-
Archive
8 REPLIES 8
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2013 09:37 AM
You can write a service task that load file contents into a process variable before your script task.
I've made something similiar, adding each recipient into a list and making the send message task multi instance…
I've made something similiar, adding each recipient into a list and making the send message task multi instance…

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2013 12:21 PM
That solution might work for some processes but not for all. In most processes / script tasks I do more complex stuff which I also want to put in an external file.
So, still no solution to my problem.
So, still no solution to my problem.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2013 10:26 PM
Hi,
I'm also using a lot of script tasks in my apps. Since I foresaw much more script maintenance than changes in the processes themselves, I've decided early in the project to always run scripts from an external source (usually file system, but could be something else, like a JCR repository). In order to achieve this, I don't use "script tasks", but regular "service tasks" that always have a expression like this:
${scriptRunner.execute('scriptname',execution)}
In this expression, "scriptRunner" is a spring bean that loads a groovy script from a process-specific location (a folder named after the process definition key, in my case).
As soon as I have some time, I'll probably simplify this using the new process parsing hooks (section 18 of the user manual). The idea would be to inject this expression at load time and adopt a convention that the script always has the same name of the task itself.
I'm also using a lot of script tasks in my apps. Since I foresaw much more script maintenance than changes in the processes themselves, I've decided early in the project to always run scripts from an external source (usually file system, but could be something else, like a JCR repository). In order to achieve this, I don't use "script tasks", but regular "service tasks" that always have a expression like this:
${scriptRunner.execute('scriptname',execution)}
In this expression, "scriptRunner" is a spring bean that loads a groovy script from a process-specific location (a folder named after the process definition key, in my case).
As soon as I have some time, I'll probably simplify this using the new process parsing hooks (section 18 of the user manual). The idea would be to inject this expression at load time and adopt a convention that the script always has the same name of the task itself.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-21-2013 07:05 AM
Sounds nice!

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2013 05:05 AM
Thanks for the hint! I implemented a similar solution. I use a regular service task which implements JavaDelegate. Filename is specified as a class parameter and the execution context is bound to the groovyscriptengine.
Cheers.
Cheers.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2015 02:21 AM
I would like to mention "external Groovy Script file" in my BPMN spec. Is it possible with Activiti?
To elaborate,
For the same script task in my workflow, different users would make use of different groovy scripts. For example, wanted to plug and play between 2 different external Groovy scripts for the same script task.
For example, I need to pick between external Groovy scripts "abc" and "xyz" on a case to case basis.
Instead of the round about ways like using Service Task and mentioning Groovy script file name like
<code>
${scriptRunner.execute('scriptname',execution)}
</code>
is it possible to mention the external Groovy script file name directly?
To elaborate,
For the same script task in my workflow, different users would make use of different groovy scripts. For example, wanted to plug and play between 2 different external Groovy scripts for the same script task.
For example, I need to pick between external Groovy scripts "abc" and "xyz" on a case to case basis.
Instead of the round about ways like using Service Task and mentioning Groovy script file name like
<code>
${scriptRunner.execute('scriptname',execution)}
</code>
is it possible to mention the external Groovy script file name directly?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2015 07:59 AM
It's not supported in the current Activiti version, but it's certainly a feature that would make a lot of sense. Can you create a JIRA issue for this?
Best regards,
Best regards,

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2015 04:12 AM
The JIRA for the above discussed feature has been created.
<BBCode>
http://jira.codehaus.org/browse/ACT-2178
</BBCode>
<BBCode>
http://jira.codehaus.org/browse/ACT-2178
</BBCode>
