cancel
Showing results for 
Search instead for 
Did you mean: 

How to get site name in activiti

mcasanket
Champ on-the-rise
Champ on-the-rise
Hi All,

   I am using activiti. I want to get the site name in my customized java class that is extending the TaskListener.

Please help!  Smiley Happy
1 REPLY 1

kevindorr
Champ in-the-making
Champ in-the-making
In order to get a site name, you can make a call to an Alfresco web script from your Activiti workflow (you can either make a call to an existing script or write your own, depending on what you want to do). There are a couple of ways to do this: you can either add a "Script Task" to the workflow, which is designed to be an automated task that just makes a script call, or you can add scripting to a user task in create or completion task listener sections of the task. Since the script task will set up a container where you can just add some Javascript code, I'll show an example of how to add code to a user task. You can add code to a user task like this:


<userTask…  (assignments etc here)>
   <extensionElements>
      <activiti:taskListnener
             event="create"
             class="org.alfresco.repo.workflow.activiti.taskListener.ScriptTaskListener>
          <activiti:field name="script">
             <activiti:string>
                <![CDATA[
                       your Javascript goes here
                ]]>
             </activiti:string>
          </activiti:field>
      </activiti:TaskListener>
   </extensionElements>
</userTask>

Elements with an "activiti:" prefix are special extensions that have been defined to help integrate Activiti with Alfresco. In this case, any Javascript calls that you make will be executed when this user task is created. There is an example of ow to call a web script from Javascript here:

http://www.unorganizedmachines.com/site/software-and-technology/34-software-development/97-calling-w...

You could also bind in the jQuery library and use it to make the call as well. I hope this helps!

Kevin Dorr
Alfresco