cancel
Showing results for 
Search instead for 
Did you mean: 

Permissions For Content in Workflow

vinaxwater
Champ in-the-making
Champ in-the-making
I have a workflow want set permission for contents in start this workflow. I config default permission for owner of content is "Coordinator" when i start this workflow this permission will removed and add permission "Consumer" (The mean: not Edit this content when workflow started with this content) for this content but i have message error: " Access Denied ". Help me ! Thanks.

This is branch when start workflow (in file process) :

<swimlane name="initiator"></swimlane>
   
   <start-state name="start">
      <task name="wf:startOfficialTask" swimlane="initiator"></task>
      <transition to="nodeSubmit" name="startLegal/Official">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
              <script>
                 <variable name="bpm_groupAssignees" access="read" />
                    <expression>if(bpm_groupAssignees == null) alert("groupAssignees is NULL");</expression>
              </script>
           </action>
      </transition>
   </start-state>

   <node name="nodeSubmit">
      <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
           <foreach>#{people.getMembers(bpm_groupAssignees)}</foreach>
            <var>user</var>
        </action>
        <event type="node-enter">
            <script>
                <expression>
                   wf_countAssignees = 0;
               wf_sizeAssignees = bpm_NTISgroupAssignees.size();               
                    if (bpm_workflowDueDate != void) { wf_dueDate = bpm_workflowDueDate; }
                    if (bpm_workflowPriority.equals("Urgent")) { wf_priority = 1; }
               if (bpm_workflowPriority.equals("Intermediate")) { wf_priority = 2; }
               if (bpm_workflowPriority.equals("Normal")) { wf_priority = 3; }
                </expression>
            <variable name="wf_dueDate" access="write" />
                <variable name="wf_priority" access="write" />
                <variable name="wf_countAssignees" access="write" />
                <variable name="wf_sizeAssignees" access="write" />              
            </script>
        </event>
      <transition to="TF">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
              <script>                
                 for (var i = 0; i &lt; bpm_package.children.length; i++)
                     {
                       var resource = bpm_package.children[i];
                       resource.setPermission("Coordinator", user.properties.userName);
                       resource.setOwner("admin");
                                resource.setPermission("Consumer", initiator.properties.userName);                       
                                resource.removePermission("Coordinator", initiator.properties.userName);                       
                        }
              </script>
            </action>
      </transition>
   </node>

   <decision name="TF">
       <event type="node-enter">
          <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
          <script>
              if(wf_Official == "Select Option"){
                alert("Please choose Legal/Official");
              }
          </script>
          </action>
           </event>
      <transition to="CRMView" name="isLegal">
         <condition>#{wf_Official == "Legal"}</condition>
      </transition>
      <transition to="OFFView" name="isOff">
         <condition>#{wf_Official == "Official"}</condition>
      </transition>
   </decision>

   <task-node name="CRMView">      
      <task name="wf:officialCRMTask">
         <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
              <pooledactorsNTIS>#{user}</pooledactorsNTIS>
           </assignment>
           <event type="task-create">
              <script>
                 <variable name="wf_dueDate" access="read,write" />
                   <variable name="wf_priority" access="read,write" />
                   <variable name="bpm_groupAssignees" access="read,write" />
                   <expression>
                      taskInstance.dueDate = wf_dueDate;
                  taskInstance.priority = wf_priority;
                  bpm_groupAssignees = null;
                   </expression>
                </script>
         </event>
      </task>
      <transition to="nodeCRM" name="Continue"></transition>
   </task-node>

Regards.
3 REPLIES 3

vinaxwater
Champ in-the-making
Champ in-the-making
I have got it with orther solution. Thanks for read!

Regards.

waoslpf
Champ in-the-making
Champ in-the-making
Hi, I am interested in setting permissions in workflow dynamically. Say, you started a workflow on a resource "R". And a user "C" does not have permission to read "R". But if a task is assigned to the user "C", I would like to make the resource "R" readable to the user "C" while the user "C" doing his task.

Could you give the complete code ? I think your workflow does this job. If it does not how may I do it ?

sebp
Champ in-the-making
Champ in-the-making
Hi, we use workflows on folders and in our case we simply assign all the users that are assigned a task as Collaborators to the bpm_package that holds the documents. I'm not sure if this works when the workflow is started on a document. Maybe you have to create a second loop that cycles through the docs of the bpm_package.


        <transition to="next" name="Next">
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                <runas>admin</runas>
                <script>
                    <variable name="bpm_assignees" access="read" />
                    <variable name="bpm_package" access="read" />
                   <expression>
                        &lt;import resource="classpath:alfresco/module/spdworkflow/workflows/spd_workflow.js"&gt;
                        for (i=0; i &lt; bpm_assignees.size(); i++) {
                            bpm_package.setPermission("Collaborator", bpm_assignees.get(i).properties["cm:userName"]);
                        }
                    </expression>
                </script>
            </action>
        </transition>