cancel
Showing results for 
Search instead for 
Did you mean: 

Automaticlly start custom workflow after upload document

maxogm
Champ in-the-making
Champ in-the-making
Hello,

I made one custom workflow, and he works OK. I also made a custom document type.

I do not know how to do:
when I upload the document how to automatically start my custom workflow.

if anyone has an example, thanks
7 REPLIES 7

thestorm
Champ in-the-making
Champ in-the-making
do it with javascript:


var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$sawf:WFPool";
workflow.parameters.requiredApprovePercent = 100;
workflow.parameters["bpm:workflowDescription"] = "Please review and approve: " + document.name;
workflow.parameters["bpm:groupAssignee"] = people.getGroup("GROUP_groupname");
workflow.execute(document);

make a business rule that executes a script on inbound (new content) and adopt the name of ur workflow (mine is sawf:WFPool) and replace groupname with a group to review it (i have pooled wf)

maxogm
Champ in-the-making
Champ in-the-making
Thanks, works

pp20218
Champ in-the-making
Champ in-the-making
Hi,

I tried the below code.But it didnt work for me.

var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$wf:review";
workflow.parameters.requiredApprovePercent = 100;
workflow.parameters["bpm:workflowDescription"] = "Please review and approve: " + document.name;
workflow.parameters["bpm:groupAssignee"] = people.getGroup("GROUP_marketing");
workflow.execute(document);

I have created 2 groups GROUP_marketing and marketing in alfresco.
I have set a rule to execute the script. But when I upload the document in that space I am getting the below error.

Error  Please correct the errors below then click OK.

    * A system error happened during the operation: 08210016 Failed to execute script 'workspace://SpacesStore/45d12735-4e2f-427a-a50c-511df0f85b1d': 08210015 Mandatory task properties have not been provided: {http://www.alfresco.org/model/bpm/1.0}assignee


Can u pls help.
Thanx

roseta
Champ in-the-making
Champ in-the-making
I would like to do the same and I understand the code and all… but, where exactly I have to writhe this code? In any specific document into any specific folder of the Alfresco directory? Thanks in advance! (I would also apreciate if you gave me some link with information about that)

pp20218
Champ in-the-making
Champ in-the-making
Hi,

The above piece of code didnt work for me, when I am using a group.But If you assign to a particular user(I mean to say hard code the value) then it is working.

What you can do is
(1) Write a javascript say (approval.js) withe the code

var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$wf:review";
workflow.parameters["bpm:workflowDescription"] = 'Approval Request for'+document.name;
workflow.parameters["bpm:assignee"] = "admin";
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 7);
workflow.parameters["bpm:workflowDueDate"] = futureDate;
workflow.execute(document);


(2) Go to a space(lets say the space name is Test) in alfresco and create a rule. The rule is to execute the script when a new document arrives.
(3)Go to Company Home/Data Dictionary/scripts and upload approval.js.
(4) So the rule will be execute approval.js when a new document arrives in "Test" space.
(5) After the document is uploaded review workflow will be initiated.

Hope this meets your requirement.

Thanx
PP

roseta
Champ in-the-making
Champ in-the-making
Thank you so much PP! I'll try it right now! =D

(btw, where have you lent it? or read it? I would like to learn to do it bymyself as well)

pp20218
Champ in-the-making
Champ in-the-making
Hi Roseta,
Even I am not 100% perfect on this.I just learnt from this wikis. with some sample example.