cancel
Showing results for 
Search instead for 
Did you mean: 

<runas> trouble

ph73nt
Champ in-the-making
Champ in-the-making
Dear listers

I have defined a workflow that moves documents after an approval cycle. My problem is that even with <runas>admin</admin> defined in my workflows, only the document creator (or owner if defined) can move a document. Here's a workflow snippet:


   <node name="publish">
      <event type="node-enter">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <runas>admin</runas>
            <script>
                  var i = bpm_package.children.length;
               var pathActive = companyhome.childByNamePath("Active");
               for (var i = 0; i &lt; bpm_package.children.length; i++){
                  bpm_package.children[i].move(pathActive);            
               }               
            </script>
         </action>
      </event>
      <transition to="end" name="End"></transition>
   </node>
I'd be happy to use <runas>creator</runas> but I get a transition error when I put anything other than admin as the runas target. I've tried:
- manually inserting my username
- putting in a swimlane name (eg initiator or manually defined "creator")
- bpm_package.children[0].properties.creator
- #{people.getPerson(bpm_package.children[0].properties.creator)}

All of which throw the same complaint about failing to signal the transition. Would someone be able to offer a solution to my problem?

Thanks in advance, Neil
6 REPLIES 6

_sax
Champ in-the-making
Champ in-the-making
Can you verify, that your transition fails because of the <runas> option? Therefore, you could change your JavaScript to something, that is possible not only for the admin, e.g. log something.
<script>
             logger.log("Here we are running as ourselves");
</script>
Other than that, is the node placed in a parallel phase of your workflow? Then possibly this http://wiki.alfresco.com/wiki/WorkflowAdministration#For_Each_Fork will get you further.

ph73nt
Champ in-the-making
Champ in-the-making
Thanks for looking

Some progress, but not yet solved. I've managed to get some logs (as you suggested) on my home system (there must be some differences between the home and business systems that I'll investigate later).

I get results when manually entering a user (eg "admin" or "nthomson" (me)), but I need to do this with code. I'd like the creator of a document as the runas argument. Do you know how this is done?

Thanks (yet again), Neil

_sax
Champ in-the-making
Champ in-the-making
Unluckily, you already tried more variants of variables, than I knew of.
Possibly, you could log all those variables, instead of using them as <runas>.
This way you could find out, if, what you build your run as statement on is what you expect it to be (usernames).
As runas seems not documented, I don't know what it can take - maybe this tag is not able to read variables and passes what you enter ("bpm_package.children[0].properties.creator") as text to the workflow processor, which then reacts not amused.

ph73nt
Champ in-the-making
Champ in-the-making
Thanks for looking. I've spent enough time on this to try a different tack. I'll just stick an extra task in for document owner and document creator and have a decision node to check for existence of the owner.

Thanks again. Neil

pasharik
Champ in-the-making
Champ in-the-making
Hello, I have the same problem, I want to use <runas> for workflow initiator. How can I do it? Thanks

rahul_mackdani
Champ in-the-making
Champ in-the-making
Try keeping your code in expression tag

<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <runas>admin</runas>
            <script>
                <expression>
                     your code
                  </expression>
                </script>
           </action>