Add content to bpm:workflowPackage via javascript/rules

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2009 11:44 AM
I've this javascript for start a my advanced workflow, but the problem born when during the initialization when I want to add more than one document to the wf.
This is the script:
for (i=0;i<space.children.length;i++){ /*Lo script viene fatto partire nella cartella "Documenti Entranti", dove verranno create le carie cartelle per i vari uffici, * per accedere a queste uso i children.*/ var nome=space.children[i].name; if (nome == "1" || nome == "2" || nome == "3"){ logger.log(nome); var rifContenutiCartella = space.children[i].children; var contenutoCont = rifContenutiCartella.length; logger.log("Contenuto sottocartella "+contenutoCont); if (presenzaContenuto(rifContenutiCartella)){ /*Aggiungo un file txt che mi raccolga tutti i nomi dei doc presi per il WF, in questo doc partirà in WF */ var docCreato = space.children[i].createFile(nome+".txt"); var contents = new Array(); docCreato.content +="ELENCO DOCUMENTI INTERESSATI NEL WORKFLOW: " for (i=0;i<rifContenutiCartella.length;i++){ contents[i] = rifContenutiCartella[i]; docCreato.content += "\r\n\r\ "+(i+1)+") "+rifContenutiCartella[i].name; } var docCreatoPDF = docCreato.transformDocument("application/pdf"); for (i=0;i<contents.length;i++){ logger.log(contents[i].name); } var workflow = actions.create("start-workflow"); workflow.parameters.workflowName = "jbpm$wfEntePAD:EntePubblico"; workflow.parameters["bpm:workflowDescription"] = "WORKFLOW"; for (i=0;i<contents.length;i++){ workflow.parameters["bpm:workflowPackage"] = contents[i]; } workflow.execute(docCreatoPDF); } }}
The workflow start with only the document "docCreatoPDF", but I want to assignee it also the contents array document…
the problem is at the end of file:
for (i=0;i<contents.length;i++){ workflow.parameters["bpm:workflowPackage"] = contents[i];}
It's possible?
Help please
THANKS
- Labels:
-
Archive

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2009 04:57 PM
for (i=0;i<contents.length;i++){ bpm_package.addNode(contents[i]); };

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2009 03:48 AM
It's rather easy to do in javascript from within the workflow. As the bpm_package is recognized as a scriptNode, we can write to it the same way we can write to any other sort of node. Your code would look something like this:for (i=0;i<contents.length;i++){ bpm_package.addNode(contents[i]); };
bpm_package is undefined…
This's the error…
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2009 03:59 AM
Are you sure you are running Alfresco script rather than Bean Shell?
Your code should be enclosed by the following tag.
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2009 04:04 AM
I don't want to put this code into a workflow, but if you see better the code, I want to put it in a javascript file (.js), that run the specific WF and add more than one file to it via this javascript…
Have you understood what I want to do?
THANKS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2009 04:24 AM
workflow.parameters["bpm:workflowPackage"] = contents;
Does not look correct if you want to pass in a collection of documents to a workflow.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2009 04:34 AM
Your line of code:
workflow.parameters["bpm:workflowPackage"] = contents;
Does not look correct if you want to pass in a collection of documents to a workflow.
And so…how can I do?
THANKS

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2009 02:53 PM
Do you have the Alfresco-SDK checked out? There is a java class test file called "JBPMEngineTest.java" under the Repository project. Look through that, it'll give you a better idea on how to do this. Though, I'm still not sure on porting it to javascript.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2009 03:21 AM
Oh, I get what you're trying to do.
Do you have the Alfresco-SDK checked out? There is a java class test file called "JBPMEngineTest.java" under the Repository project. Look through that, it'll give you a better idea on how to do this. Though, I'm still not sure on porting it to javascript.
Thanks, but I've solved writing the javascript in the start-node of the wf…
THANKS A LOT FOR THE RESPONSE

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2009 06:32 AM
Thanks
