cancel
Showing results for 
Search instead for 
Did you mean: 

Assignment Event in workflow

irenailievska1
Champ in-the-making
Champ in-the-making
Hi,
I have a bit of a problem with Activiti. I wish to add permission for viewing a document to a candidate group. But if I use the assignment event that is integrated in a user task, then when I click to finish the task - the task doesn't redirect. It stays on the same window and if I go Home the task is finished - removed from the My tasks dashlet. If I remove the assignment event then everything works fine.
I found out that the assignment event fires before create task, on save and close button, reassign, and in my case on Claim button - so when the task is assigned to a group the permissions are added only to the person that claims the task.
Below is a part of the code I am using. Any kind of help is welcomed.

<userTask id="task1" name="task 1" activiti:candidateGroups="${swf_archive1.properties.authorityName}" activiti:formKey="swf:taskFirst">
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[
                                      //////////////some code
                            ]]></activiti:string>
          </activiti:field>
          <activiti:field name="runAs">
            <activiti:string><![CDATA[admin]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="assignment" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[var userName = task.assignee;
                      
                     for(var i = 0; i < bpm_package.children.length; i++) {

                        var resource = bpm_package.children;
                        
                        if(!resource.getSiteShortName()){
                           resource.setPermission("Consumer", userName);
                        }   
                         else
                         {
                           var siteName = resource.getSiteShortName();
                           var site = siteService.getSite(siteName);
                           if(!site.isMember(userName)){
                              resource.setPermission("Consumer", userName);
                              
                           }
                        }
                  }]]></activiti:string>
          </activiti:field>
          <activiti:field name="runAs">
            <activiti:string><![CDATA[admin]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[
                                       //////////////some code
                  ]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>


Thanks in advanced,
Irena
1 REPLY 1

jbarrez
Star Contributor
Star Contributor
Not sure - as this is an Alfresco specific thing.
It seems the alfresco UI would need to refresh automatically, but it doesn't. Not sure how that would be done :s