cancel
Showing results for 
Search instead for 
Did you mean: 

Move space after advanced workflow.

vidya_r
Champ in-the-making
Champ in-the-making
Hi Anyone,

I am calling a group_parallel review workflow for a space through javascript as given below…


var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$wf:parallelgroupreview";
workflow.parameters.requiredApprovePercent = 20;
workflow.parameters["bpm:workflowDescription"] = "Please review and approve: " + document.name;
workflow.parameters["bpm:groupAssignee"] = people.getGroup("GROUP_reviewers");


I have applied the rule to type = space. So anytime a new space is added, the reviewers get the the task.
But once the task is completed or the workflow is done I want to move the space to another location or space.
How can I go about this?  Can anyone help?

Can I do this through script in the workflow definition?
5 REPLIES 5

vidya_r
Champ in-the-making
Champ in-the-making
Any ideas any one?



In the parallelreview_group_processdefinition

I have this
<transition name="approve" to="approved">
            <condition>#{wf_actualPercent >= wf_requiredApprovePercent}</condition>        
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                   <script>
                      var dest = companyhome.childByNamePath("draft");
                      bpm_context.move(dest);
                   </script>
  </action>
          </transition>



Is this right?
bpm_context.move(dest);

or should it be

bpm_package.move(dest); (this gives error)


I need to get the space on which the workflow is run to move. Any help is greatly appreciated.

Thanks
Vidya

sethatrothbury
Champ in-the-making
Champ in-the-making
I've never run a workflow on a space, actually didn't think it would let you, but the idea should be the same as moving an item thats in a workflow.


var dest = companyhome.childByNamePath("draft");
bpm_package.children[0].move(dest);

If the space is in the workflow package, it should appear as the first child of that package. Like I said though, I've never tried this on a space/folder, only on content items.

vidya_r
Champ in-the-making
Champ in-the-making
Thank you Seth. 

I tried your suggestion. But it does not move the space.

I find that none of the workflow parameters are accessible for space in the workflow definition.
Even if I try to copy the contents, it is not allowing me to do so.  Is there any other way to achieve this.
My scenario is after the workflow on a space I need to move the space along with contents inside to a different space.

sethatrothbury
Champ in-the-making
Champ in-the-making
Your best bet is to create a new space and move the contents from your starting space into it.

This is some code I've used in the past that does something sort of like that:


if (wf_department != "")
{
   var departmentSpace = companyhome.childByNamePath("Departments");
   var department = departmentSpace.childByNamePath(wf_department);
   if ( department != null)
   {
      var newFolder = department.childByNamePath(bpm_workflowDescription);
            
      if ( newFolder == null )
      {
         if ( !department.hasPermission("CreateChildren") )
         {
            var mail = actions.create( "mail" );
            mail.parameters.to = initiator.properties.email;
            mail.parameters.subject = bpm_workflowDescription + " workflow error.";
            mail.parameters.from = "oscar@alfresco.bedfordstmartins.com";
            mail.parameters.text =  " You do not have the necessary permissions to create files in the " + wf_department + " Space.";
            mail.execute( bpm_package );
         }
         else
         {
            newFolder = department.createFolder(bpm_workflowDescription);
         }
      }
                  
      for (var i = 0; i &lt; bpm_package.children.length; i++)
      {
         bpm_package.children[i].move(newFolder);
      }
   }
}

'wf_department' is set to the name of a space I want to move files into. Then we just check if we have permissions, create the space, then move files into it.

vidya_r
Champ in-the-making
Champ in-the-making
Thank you for the reply again Seth. I tried out above code one last time with runas  admin. It worked. I don't know if this was the real cause as I was not getting any permission errors earlier. I will try out your next suggestion too if  I run into problems with this.

children[0] currectly points to the space and moves the contents perfectly.



 <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
             <runas>admin</runas>
       <script>   
             var dest= companyhome.childByNamePath("Approved");                         
         bpm_package.children[0].move(dest);
       </script>
</action>