Create document as workflow step

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2010 10:05 AM
Hi,
One of my advanced workflow steps should be document creation. User should enter his text and then simple text document should be created.
May be somebody could suggest how to do that from workflow?
Thanks
One of my advanced workflow steps should be document creation. User should enter his text and then simple text document should be created.
May be somebody could suggest how to do that from workflow?
Thanks
Labels:
- Labels:
-
Archive
5 REPLIES 5

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2010 02:06 PM
that is very easy: asuming that you know something about wf-s, you define type where you have prop defined. user will have to enter value to this.
<types><type name="scwf:submitHelloWorldTask"><parent>bpm:startTask</parent><properties><property name="scwf:helloName"><type>d:text</type><mandatory>true</mandatory><multiple>false</multiple></property></properties></type>
// create file, make it versionablevar doc = userhome.createFile("checkmeout.txt");doc.addAspect("cm:versionable");doc.content = "original text";// check it out and update content on the working copyvar workingCopy = doc.checkout();workingCopy.content = "updated text 1";// check it indoc = workingCopy.checkin();// check it out againworkingCopy = doc.checkout();workingCopy.content = "updated text 2";// check it in again, but with a version history note and as major version incrementdoc = workingCopy.checkin("a history note", true);
this would be how to create docs with text , update it ect.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2010 01:17 AM
Thanks for reply,
I need to create document in the same folder as the bpm_package.children[0] element is. How to do that? And if I understand correctly I could use text from task element for my document content, but I didn't understand fully how to do that?
I need to create document in the same folder as the bpm_package.children[0] element is. How to do that? And if I understand correctly I could use text from task element for my document content, but I didn't understand fully how to do that?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2010 08:23 AM
you want to create document and add it into workflow.
so you create doc somewhere on the system and add it to workflow and then add it to list. try it a few times and you will hit it.
also alfresco javascript has same features as genuin java script so you can deal with arrays…
so you create doc somewhere on the system and add it to workflow and then add it to list. try it a few times and you will hit it.
also alfresco javascript has same features as genuin java script so you can deal with arrays…

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2010 08:43 AM
Thanks,
But it is not functionality I need. Final my workflow step is: user should write comment and reason (2 text field should be field). Then he presses "next step" button simple text document should be created in Alfresco (content = field1 + field2 text) and the same file should be registered in external system.
If I am not clear enough please contact me ASAP, because for me is really important to get answer as quick as possible.
But it is not functionality I need. Final my workflow step is: user should write comment and reason (2 text field should be field). Then he presses "next step" button simple text document should be created in Alfresco (content = field1 + field2 text) and the same file should be registered in external system.
If I am not clear enough please contact me ASAP, because for me is really important to get answer as quick as possible.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2010 02:53 PM
I have not tested the code but this should work. Add this code to any of your nodes in the workflow.
http://wiki.alfresco.com/wiki/3.3_JavaScript_API#Modifying_and_Creating_API
http://wiki.alfresco.com/wiki/JavaScript_API_Cookbook
http://wiki.alfresco.com/wiki/WorkflowAdministration#Actions_.26_Scripting
<event type="node-enter"> <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript"> <runas>admin</runas> <script> <expression>var doc = bpm_package.createFile("checkmeout.txt");doc.content = "original text";</expression></script></action></event>
Please look at the following:http://wiki.alfresco.com/wiki/3.3_JavaScript_API#Modifying_and_Creating_API
http://wiki.alfresco.com/wiki/JavaScript_API_Cookbook
http://wiki.alfresco.com/wiki/WorkflowAdministration#Actions_.26_Scripting
