cancel
Showing results for 
Search instead for 
Did you mean: 

Check out document in workflow

ph73nt
Champ in-the-making
Champ in-the-making
Dear Alfresco users

I'm attempting to code a workflow that will eventually include a document check-out. So far I've had trouble referencing documents. I've created a basic workflow with a small script taken from the lifecycle model on the wiki (http://wiki.alfresco.com/wiki/WorkflowSample_Lifecycle). As soon as I run the workflow with script that include bpm_package.children[x], I get the famous error:
Failed to signal transition null from workflow task jbpm$xxx
If I remove this and keep something like var len = bpm_package.children.length;, it runs OK. Could anybody point me in the right direction? Anything to do with being in a "node?" Here's my code snippet:

   <node name="CheckOut">
      <transition to="End" name="Check out"></transition>
      <event type="node-enter">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <runas>admin</runas>
            <script>
               var path = userhome.properties.name
               for (var i = 0; i &lt; bpm_package.children.length; i++)
               {
                  if (!bpm_package.children[i].hasAspect("wfl:status"))
                  {
                     bpm_package.children[i].addAspect("wfl:status");
                  }
               }                           
            </script>
         </action>
      </event>
   </node>

Thanks in advance, Neil
2 REPLIES 2

_sax
Champ in-the-making
Champ in-the-making
The code looks okay to me. Did you already try to let the script run without any action (checking for and adding the aspect, that is)?


   <node name="CheckOut">
      <transition to="End" name="Check out"></transition>
      <event type="node-enter">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <runas>admin</runas>
            <script>
               var path = userhome.properties.name
               for (var i = 0; i &lt; bpm_package.children.length; i++)
               {
                  i = i;
               }                          
            </script>
         </action>
      </event>
   </node>

To debug your workflow this could be of help: http://ecmarchitect.com/archives/2008/03/10/814 (You have to be logged in as admin to get to the pages). Then there's the debug functionality for any Javascript logging mentioned in the article:  in <ALFRESCO WEB ROOT>/WEB-INF/classes/log4j.properties switch log4j.logger.org.alfresco.repo.jscript.AlfrescoRhinoScriptDebugger=off
to
log4j.logger.org.alfresco.repo.jscript.AlfrescoRhinoScriptDebugger=on

But again, your workflow looks okay.

ph73nt
Champ in-the-making
Champ in-the-making
Thanks for pointing me to logging. I ammended the property you suggested:
log4j.logger.org.alfresco.repo.jscript.AlfrescoRhinoScriptDebugger=on
which prevented the server from booting correctly (ie no Alfresco). I ammended this (and the next couple of lines) to:
log4j.logger.org.alfresco.repo.web.scripts.AlfrescoRhinoScriptDebugger=info
log4j.logger.org.alfresco.repo.jscript=info
log4j.logger.org.alfresco.repo.jscript.ScriptLogger=info
Started the server and the workflow now works. I'm at a loss as to explain this and have to put it down to magic. I'd already tried a server restart and had ruled that out yesterday. Next time I break the workflow I'll write down what I did.

Cheers, Neil