Workflow Upload field
Upload is used to upload a document.
| Attribute | Description | Required |
|---|---|---|
| label |
The text shown as a label in the user interface. |
true |
| name |
Unique name identifier. Two fields cannot have the same name in the same task definition. The name must be unique. |
true |
| width |
The width of the HTML element. In the case of KCenter, the UI must use width values based on %, for example:
|
false |
| data |
When present, it is an identifier used to load data. For example, dynamically set the folderPath or folderUuid. |
false |
|
type |
Values:
When it is not present, the default value is set to "create". |
false |
| folderPath |
The folder path where the document will be stored. |
false |
| folderUuid | The folder UUID where the document will be stored. | false |
| documentName | Forced name of the uploaded document. | false |
| documentUuid | The UUID of the document to be updated. | false |
|
allowedExtensions |
Set the document extensions that are allowed to be uploaded. For example: pdf;png |
false |
|
multiple |
When |
false |
|
To upload a new document, you should set the folderPath or folderUuid, and optionally documentName if you want to force the document name. To update an existing document, you should set the document UUID and set the type to "update".
Child elements:
|
||
Basic upload example
- Upload a new document to a folder.
- folderUuid is a valid folder UUID. You can also use folderPath and set a path, which is more human-readable.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE workflow-forms PUBLIC "-//OpenKM//DTD Workflow Forms 2.6//EN" "http://www.openkm.com/dtd/workflow-forms-2.6.dtd"> <workflow-forms> <workflow-form task="upload test"> <upload name="upload" label="Upload document" folderUuid="fca2d85e-0e01-418d-b699-c0dd0f8190da" /> </workflow-form> </workflow-forms>
Document update example
- Create a new version of an existing document.
- documentUuid is the UUID of the document to be updated.
- The type attribute must be set to
update.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow-forms PUBLIC "-//OpenKM//DTD Workflow Forms 2.6//EN"
"http://www.openkm.com/dtd/workflow-forms-2.6.dtd">
<workflow-forms>
<workflow-form task="upload test">
<upload name="upload" label="Upload document" type="update" documentUuid="e6a06309-c1cf-42be-98fd-7d7ed83ebda8" />
</workflow-form>
</workflow-forms>
Dynamic parameters example
- Upload a document to a folder determined at runtime.
- The data attribute is a mapping variable used to dynamically set the
folderPathorfolderUuidattribute.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow-forms PUBLIC "-//OpenKM//DTD Workflow Forms 2.6//EN"
"http://www.openkm.com/dtd/workflow-forms-2.6.dtd">
<workflow-forms>
<workflow-form task="upload test">
<upload name="upload" label="Upload document" data="updData" />
</workflow-form>
</workflow-forms>
The following Java code must be executed before the task that displays the form. It sets the target folder dynamically:
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;
import com.openkm.bean.form.Upload;
public class UploadAction implements ActionHandler {
private static final long serialVersionUID = 1L;
@Override
public void execute(ExecutionContext ctx) throws Exception {
Upload upd = new Upload();
upd.setFolderPath("/okm:root/dstFld");
ctx.setVariable("updData", upd);
// Proceed to the next node
ctx.getToken().signal();
}
}