Start workflow via JavaScript with the help of rules
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2008 06:06 AM
I want to create a rule, with the "execute a script" actions. I want to start the advanced workflow with the help of the rules.
Actually I want to automaticly start the workflow by adding a new content.
for example:
a user adds a content
the (whitepaper) workflow starts in backgroound and send a task for a specific users,
these users recieve a task on their pool tasks list.
Is it possible to start a workflow by defining a rule, at the time of adding a new content????
I guess one solution is to use the javascript in the rule definition, but how should the script look like?
Thank you,
FSB
- Labels:
-
Archive

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2008 08:03 AM
var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$wf:adhoc";
workflow.parameters["bpm:workflowDescription"] = "The attached document has been uploaded to Alfresco. Please review within 3 days.";
workflow.parameters["bpm:assignee"] = "admin";
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 3);
workflow.parameters["bpm:workflowDueDate"] = futureDate;
workflow.execute(document);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2008 09:08 AM
I could start my workflow with the help of your code.
but I don't want to hard code the value of the aspects, for example I want the 'bpm:assignee' be stable, and when the workflow starts automatically, at that time I wanna be able to assign the person, or any other values, like dates, Description or any other values.
How can I do that???
Thank you,
FSB

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2008 11:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2008 12:08 AM
ya, exactly, I want to provide a UI for getting that values from the user.
Is there any other solution, except UI, and also hard coding?
and for assigning a task to multiple user, should we write like these??
workflow.parameters["bpm:assignees"] = "admin, X, Y";
Thank you again,
FSB.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2008 07:57 AM
1) Write your own JSF UI component that displays a form to capture the data and execute your workflow.
2) Call a custom HTML form that captures the data and posts it to a web script that uses the form data to execute the workflow.
3) Capture the relevant workflow data on the document itself. i.e your document could have a 'reviewers' property (maybe defined by an aspect that is applied to document). Your 'start workflow' Javascript rule could read this data from the document properties and use this as the parameters to execute the workflow.
The best approach depends on your use case, Alfresco and Java knowledge. Option 3 probably requires the least amount of coding….

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2008 01:43 PM
Have a look at the following wiki page:
http://wiki.alfresco.com/wiki/Dialog_And_Wizard_Framework
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2008 01:36 AM
Mike's help was usefull and Claudio's completed it!
Thank you again
FSB,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2017 06:17 AM
How You did this one? can you give me idea..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2008 02:06 PM
In the sample script posted here, it uses "document" object directly. For some reason, I keep getting error of "ReferenceError: 'document' is not defined". I was told that 'document' is one of the root object that is not available to web script JS scripts. Is there some other way to provide a file to the execute() method. I'm hoping to achieve passing a file that is already exist in the repository.
Much appreciate any suggestion.
Thanks.
