cancel
Showing results for 
Search instead for 
Did you mean: 

Using workflow dashlet 'Approve' in a business rule/js.

rbkprod
Champ in-the-making
Champ in-the-making
Hi

I have a small .js script implemented with a business rule in a space, say "space1", that adds a review workflow to a specific user when a file is uploaded in space1.


var workflow = actions.create("start-workflow");
var user = people.getPerson("user1");
workflow.parameters.workflowName = "jbpm$wf:review";
workflow.parameters["bpm:workflowDescription"] = document.name;
workflow.parameters["bpm:assignee"] = user;
workflow.execute(document);

This works fine, and the document name shows up when 'user1' logs on, in his default My Alfresco -> My tasks dashlet. I was wondering if it's possible to use the "Approve" or "Reject" buttons on the dashlet though? Say if user1 clicks on "Approve" on the dashlet the document gets moved to a different location, same for "Rejeted". I don't quite have any thoughts on how to approach this, any help is much appreciated.

Thanks
3 REPLIES 3

rajanigupta
Champ in-the-making
Champ in-the-making
hiii

Hope this would help you…..
assuming that both spaces depends on the same root space, you should use something like this in your process definition:

<task-node name="approved">
<task name="wf:approvedParallelTask" swimlane="initiator" />
<transition to="end">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<runas>admin</runas>
<script>
<variable name="bpm_package" access="read" />
<expression>
var origin = bpm_package.children[0].parent;
var root = origin.parent;
var destination = root.childByNamePath("approved");
if (destination == null)
{
destination = origin.createFolder("approved");
}
                                                      
for (var i=0; i &lt; bpm_package.children.length; i++)
{
     bpm_package.children.move(destination);
}  
</expression>
</script>
</action>
</transition>
</task-node>

rbkprod
Champ in-the-making
Champ in-the-making
Hey there.

Thanks for the reply. Smiley Happy

I would like to know wich process def to use though, 'review_processdefinition.xml' probably right? I will give it a go later on and let you know.

Thanks !

thestorm
Champ in-the-making
Champ in-the-making
try define your own one, should work better for you, but u can use that one as reference Smiley Wink