cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow package

zummy
Champ in-the-making
Champ in-the-making
Hi,

I'm new in Alfresco. I would like to setup a new workflow in which one of the task should move the package (i.e. document) from one folder to another. Could someone send me some tips or links to examples. FYI, I'm currently investigating implementation of the interface JBPMSpringActionHandler to see if I can do that there.

Thks,
Christophe
8 REPLIES 8

ribz33
Champ on-the-rise
Champ on-the-rise
Sure its possible.
look here for more help:
http://wiki.alfresco.com/wiki/WorkflowAdministration

you need to define a script in your task which move document to another space.
If you do move you will have probably problem with rights because workflow use current user rights. So user who start workflow need enough right to delete in current space and write in destination space.

Another thing you will need to write in hard in your script destination space because at the moment there is no space selector available in workflow web client interface.

I hope this help Smiley Happy

zummy
Champ in-the-making
Champ in-the-making
Thanks for the answer.

If we put aside permission problems I still have the question of how do I do the move using a script? Is there any AlfrescoJavascript document reference somewhere? Should I use the bpm_package in this case? If so what kind of operation can I run on this object?

Can't I do that by calling an ActionHandler?
i.e. <action name="moveDocument" class="my.workflow.WorkflowMoveDocument"></action>

Thanks again.
Christophe

ribz33
Champ on-the-rise
Champ on-the-rise
You can use that to do move

<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
  var dest = bpm_context.childByNamePath("DestFolder");
  for (var i = 0; i &lt; bpm_package.children.length; i++)
  {
   bpm_package.children[i].move(dest);
  }    
</script>
</action>

This code move package to current folder to children folder "DestFolder"

But that can working only for admin and coordinator users.
In other way you need to define dedicated permissions to do move !

guiyan17
Champ in-the-making
Champ in-the-making
But that can working only for admin and coordinator users.
In other way you need to define dedicated permissions to do move !

Hello ribz33,

Hum I'm sorry but how do you define dedicated permissions? Is there any wiki on that?  :roll:

Thanks a lot,

Yannick

blackout
Champ in-the-making
Champ in-the-making
Just a hint,

if you check the code from SVN (here) you can read this:
public Node childByNamePath(String path)
{

}
// TODO: find out why this doesn't work - the function defs do not seem to get found
I suggest you use
public Node[] childrenByXPath(String xpath)
You just have to learn XPath syntax and JSR170 specification on repository navigation if you don't know them already.

kevinr
Star Contributor
Star Contributor
Just a hint,

if you check the code from SVN (here) you can read this:
public Node childByNamePath(String path)
{
&#8230;
}
// TODO: find out why this doesn&#39;t work - the function defs do not seem to get found
.

That code comment is unrelated to the function above - which does work. The comment is related to the fact that the Rhino JavaScript engine should pickup function definitions defined as methods with the jsFunction_ prefix - but it doesn&#39;t seem to so we fall back to use bean style method definitions instead.

Thanks,

Kevin

blackout
Champ in-the-making
Champ in-the-making
I wronged something then, but I roughly used the code directly from the wiki, just with different folder names…but that's offtopic here, thanks anyway Kevin

guiyan17
Champ in-the-making
Champ in-the-making
hum okay thank you  :wink:
So the function "childrenByXPath" solve problem of permission or not?  :?:

To sum-up, I have got this code to copy a document to "Alfresco/Espace1":


         
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
    <script>
   var myRoot=bpm_context.parent;
   var myUserhome=initiator.properties['cm:homeFolder'];
   var archiveFolder = myRoot.childByNamePath("Alfresco/Espace 1");
   for (var i = 0; i &lt; bpm_package.children.length; i++) {
      bpm_package.children[i].copy(archiveFolder);
   } 
   
    </script>
</action>

It works very well when I'm logged as admin, but I'm a simple guest or contributor, it seems that it doesn't work??!!

So I have to "learn XPath syntax and JSR170 specification on repository navigation" to make it working??" or just use the function "childrenByXPath"?

Thank very well for your assistance…

Yannick