cancel
Showing results for 
Search instead for 
Did you mean: 

Create document as workflow step

inocka
Champ in-the-making
Champ in-the-making
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
5 REPLIES 5

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
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 versionable
var doc = userhome.createFile("checkmeout.txt");
doc.addAspect("cm:versionable");
doc.content = "original text";

// check it out and update content on the working copy
var workingCopy = doc.checkout();
workingCopy.content = "updated text 1";

// check it in
doc = workingCopy.checkin();

// check it out again
workingCopy = doc.checkout();
workingCopy.content = "updated text 2";

// check it in again, but with a version history note and as major version increment
doc = workingCopy.checkin("a history note", true);
this would be how to create docs with text , update it ect.

inocka
Champ in-the-making
Champ in-the-making
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?

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
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…

inocka
Champ in-the-making
Champ in-the-making
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.

solo8788
Champ in-the-making
Champ in-the-making
I have not tested the code but this should work.  Add this code to any of your nodes in the workflow.


<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