cancel
Showing results for 
Search instead for 
Did you mean: 

Adding/Removing aspects on document

doblek
Champ in-the-making
Champ in-the-making
Hi all,

I'm trying to add (and remove) some custom aspects on a document which is involved in an "approved/rejected workflow"…

So I've modified the "review_processDefinition.xml" (see code below) in order to add the new aspects defined in a new custom model. I think the model is properly registered in the repository (since the aspects are available in the web client), but when I click on "Start Advanced Workflow » Review & Approve", fill out the form displayed and click on "Finish", no aspect is applied to the document. No exception arises, but the workflow behavior is the same as if I would make no modifications… =(

Can anybody tell me where is my error?? Should I import my model from the workflow model??

Any help appreciated.

Regards,
Enrique


PS: here is my new "review_processDefinition.xml"

<?xml version="1.0" encoding="UTF-8"?>

<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="wf:review">

    <swimlane name="initiator" />

    <start-state name="start">
        <task name="wf:submitReviewTask" swimlane="initiator" />
        <transition name="" to="review">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               bpm_package.children[0].addAspect("dsm:docStatus_PendingApproval");
               bpm_package.children[0].save();
            </script>
         </action>
      </transition>
    </start-state>

    <swimlane name="reviewer">
        <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
            <actor>#{bpm_assignee}</actor>
        </assignment>   
    </swimlane>

    <task-node name="review">
        <task name="wf:reviewTask" swimlane="reviewer">
            <event type="task-create">
                <script>
                    if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
                    if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
                </script>
            </event>
        </task>
        <transition name="reject" to="rejected">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               bpm_package.children[0].removeAspect("dsm:docStatus_PendingApproval");
               bpm_package.children[0].addAspect("dsm:docStatus_Rejected");
               bpm_package.children[0].save();
            </script>
         </action>
      </transition>
        <transition name="approve" to="approved">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               bpm_package.children[0].removeAspect("dsm:docStatus_PendingApproval");
               bpm_package.children[0].addAspect("dsm:docStatus_Approved");
               bpm_package.children[0].save();
            </script>
         </action>
      </transition>
    </task-node>

    <task-node name="rejected">
        <task name="wf:rejectedTask" swimlane="initiator" />
        <transition name="" to="end" />
    </task-node>

    <task-node name="approved">
        <task name="wf:approvedTask" swimlane="initiator" />
        <transition name="" to="end" />
    </task-node>

    <end-state name="end" />

</process-definition>

The following aspects are defined in my model:

    <aspect name="dsm:docStatus_PendingApproval">
    <aspect name="dsm:docStatus_Rejected">
    <aspect name="dsm:docStatus_Approved">
3 REPLIES 3

doblek
Champ in-the-making
Champ in-the-making
I think there is something wrong with my script tag…

I've been replacing the scripting code to check several issues, but I got no success =(

I've tested the following code (to check if the problem were my custom aspects):

<start-state name="start">
     <task name="wf:submitReviewTask" swimlane="initiator" />
     <transition name="" to="review">
          <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <script>
                    bpm_package.children[0].addAspect("cm:versionable");
                    bpm_package.children[0].save();
               </script>
          </action>
     </transition>
</start-state>

but the document has no version history…


So I've checked this script in order to know if it was executing anything:

<start-state name="start">
     <task name="wf:submitReviewTask" swimlane="initiator" />
     <transition name="" to="review">
          <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <script>
                    if (logger.isLoggingEnable()){
                         logger.log("Starting test…");
                    }
                    if (logger.isLoggingDebug()){
                         logger.debug("Starting test 2…");
                    }
               </script>
          </action>
     </transition>
</start-state>

But, though I've inserted the following lines in the log4j.properties file (in alfresco/WEB-INF/classes😞

log4j.logger.org.alfresco.repo.workflow=info
log4j.logger.org.alfresco.repo.jscript=DEBUG

it does not write any message in the log =(


Any advice is appreciated 😃

Thanks in advance and regards,
Enrique

doblek
Champ in-the-making
Champ in-the-making
Hi,

I finally managed to solve this issue… the problem was that I didn't enable workflow definition's redeployment…  Smiley Surprisedops:  Smiley Surprisedops:  Smiley Surprisedops: so Alfresco was unable to catch the changes…

Regards.

hogarth503
Champ in-the-making
Champ in-the-making
Hi,
I am new to Alfresco and was reading your post, I am trying to do the same thing as you describe. I want a form to appear, as soon as a person take ownership of the task. the person fill  out the form and save it. and the workflow continued. would you please explain what part of your code generate and display the form.. perhaps post any additional code that will help me get started.

Any help would be really appreciated.

Thanks.