cancel
Showing results for 
Search instead for 
Did you mean: 

Information about initiator of submitted content

davix
Champ in-the-making
Champ in-the-making
Hi,

I'm trying to customize Alfresco's serial workflow. Normally what happens is if there are 4 users User1,User2,User3,User4 and if any user submits content, it always goes to User1. I'm trying to change this behavior so that when User1 submits content it should go to User2 and when User2 submits content it should go to User3 and when User3 submits content it should go to User4.

Now in \alfresco\WEB-INF\classes\alfresco\workflow\submit_processdefinition.xml I need to identify the user who submitted the content so that I can then send it to the next user for review. Here's where I'm modifying.
<decision name="serialorparallel">
       <event type="node-enter">
            <script>
               <variable name="wcmwf_reviewerCnt" access="write"/>
               <variable name="wcmwf_approveCnt" access="write"/>
               <variable name="wcmwf_reviewType" access="write"/>
               <expression>
                  wcmwf_reviewerCnt = bpm_assignees.size();
                  wcmwf_approveCnt = 0;
                  wcmwf_reviewType = wcmwf_submitReviewType;
               </expression>
            </script>
       </event>

       <transition name="serial" to="submitserialreview" />
       <transition name="parallel" to="submitparallelreview">
          <condition>#{wcmwf_reviewType == "Parallel"}</condition>
       </transition>
    </decision>
Since wcmwf_approveCnt is always 0, normally content always goes to the first user. I wanted to modify this so that wcmwf_approveCnt can be = (the current user who submitted the content) + 1. This way the content would go to the next user. I know of this –> initiator.properties["cm:name"]; but I guess that's wrong. Is there a correct way to achieve this.

Please let me know, thanks!
2 REPLIES 2

davix
Champ in-the-making
Champ in-the-making
I've tried to modify as shown below.

            <script>
               <variable name="wcmwf_reviewerCnt" access="write"/>
               <variable name="wcmwf_approveCnt" access="write"/>
               <variable name="wcmwf_reviewType" access="write"/>
          <variable name="initiator" access="write"/>
          <variable name="count" access="write"/>
                <expression>
                 wcmwf_reviewerCnt = bpm_assignees.size();
                 wcmwf_reviewType = wcmwf_submitReviewType;
       initiator = initiator.properties["cm:name"];
       for(count = 0; count &lt; wcmwf_reviewerCnt; count++)
              {
               if(initiator == bpm_assignees.get(count))
               {
                  break;
               }
              }
              wcmwf_approveCnt = count + 1;
           </script>

But I'm getting this error
javax.faces.FacesException: Error calling action method of component with id dialog:finish-button
caused by:
javax.faces.el.EvaluationException: Exception while invoking expression #{DialogManager.finish}
caused by:
org.alfresco.error.AlfrescoRuntimeException: 05240005 Failed to submit to workflow
caused by:
org.alfresco.service.cmr.workflow.WorkflowException: 05240004 Failed to signal transition null from workflow task jbpm$20.
caused by:
org.jbpm.graph.def.DelegationException: Sourced file: inline evaluation of: `` wcmwf_reviewerCnt = bpm_assignees.size(); w . . . '' : Not an array
caused by:
Sourced file: inline evaluation of: `` wcmwf_reviewerCnt = bpm_assignees.size(); w . . . '' : Not an array : at Line: 4 : in file: inline evaluation of: `` wcmwf_reviewerCnt = bpm_assignees.size(); w . . . '' : [ "cm:name" ]

Please let me know where I'm going wrong, thanks!

davix
Champ in-the-making
Champ in-the-making
The error is due to incorrect usage of initiator.properties["cm:name"]. So I've modified the code as show below.

<script>
               <variable name="wcmwf_reviewerCnt" access="write"/>
               <variable name="wcmwf_approveCnt" access="write"/>
               <variable name="wcmwf_reviewType" access="write"/>
               <variable name="initiatorName" access="write"/>
               <variable name="count" access="write"/>
                <expression>
                  wcmwf_reviewerCnt = bpm_assignees.size();
                  wcmwf_reviewType = wcmwf_submitReviewType;
                  initiatorName = initiator.properties.get("firstName");
                  for(count = 0; count &lt; wcmwf_reviewerCnt; count++)
                   {
                    if(initiatorName == bpm_assignees.get(count))
                    {
                     break;
                    }
                   }
                   wcmwf_approveCnt = count +1;
               </expression>
</script>
Now any content I submit gets rejected and comes back to the initiator. I guess this is because of the incorrect comparison in the if part.
if(initiatorName == bpm_assignees.get(count))
What does bpm_assignees contain. First Names or Last Names.

Would be great if someone can help me on this. Thanks!