• Help Creating Workflow

  • He we will discuss about how to make customization and improvement to the OpenKM source code.
He we will discuss about how to make customization and improvement to the OpenKM source code.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #11236  by andrew.cy
 
I'm trying to create a workflow that creates a folder and moves a file to it. However I have been unsuccessful and cannot even add a folder. Im implementing the logic in the action handler of the node that is supposed to create this folder. Any suggestions are greatly appreciated?
 #11244  by andrew.cy
 
heres the process definition
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>

<process-definition  xmlns="urn:jbpm.org:jpdl-3.2"  name="Test">

	<start-state name="start">
		<transition to="clientInfo"></transition>
	</start-state>

	<task-node name="clientInfo">
		<task name="File Delegation">
			<assignment actor-id="okmAdmin"></assignment>
			<event type="task-create">
				<script>
					taskInstance.start();
				</script>
			</event>
		</task>
		<transition to="moveFile"></transition>
	</task-node>

	<node name="moveFile">
		<action class="com.Test.TestHandler"></action>
		<transition to="end"></transition>
	</node>

	<end-state name="end"></end-state>

</process-definition>
the forms.xml
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow-forms PUBLIC "-//OpenKM//DTD Workflow Forms 1.0//EN"
                                "http://www.openkm.com/dtd/workflow-forms-1.0.dtd">
<workflow-forms>
  <workflow-form task="File Delegation">
    <input label="Enter Client's First Name" name="firstName" />
    <input label="Enter Client's Last Name" name="lastName" />
    <button label="Submit" />
  </workflow-form>
</workflow-forms>
here is the Handler implementation
Code: Select all
package com.Test;

import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;

import com.openkm.api.OKMAuth;
import com.openkm.api.OKMDocument;
import com.openkm.api.OKMFolder;
import com.openkm.bean.form.Input;

public class TestHandler implements ActionHandler 
{
	private static final long serialVersionUID = 1L;
	String firstName;
	String lastName;

	public void execute(ExecutionContext context) throws Exception 
	{		
		firstName = context.getContextInstance().getVariable("firstName").toString().trim();
		lastName = context.getContextInstance().getVariable("lastName").toString().trim();
		
		String token = OKMAuth.getInstance().login("okmAdmin", "admin");
		Input DP = (Input) context.getContextInstance().getVariable("path");
		String docPath = DP.getValue().trim();
		
		if (!OKMFolder.getInstance().isValid(token, "/okm:root/" + lastName + ", " + firstName))
			OKMFolder.getInstance().createSimple(token, "/okm:root/" + lastName + ", " + firstName);
		
		OKMDocument.getInstance().move(token, docPath, "/okm:root/" + lastName + ", " + firstName);
		context.leaveNode();
	}
}
 #11249  by andrew.cy
 
I figured it out you just need to play with the above code a little and use try catch blocks anyway is there a way to refresh the foldertree through a workflow?
 #11281  by jllort
 
You're talking about workflow could made some operations with user interface, like refreshing folders tree etc..., is that the idea ?
 #11282  by andrew.cy
 
yes that exactly my idea for a workflow. Also, why can't I use the api classes to write a tab document extension. I keep getting an error that states "no source code found for com.openkm.api.OKMFolder did you forget to inherit a module"
 #11290  by jllort
 
Please post the question about TabDocument in other thread.

Actually there's no way to refreshing UI in a workflow process, but really seems interesting and necessary feature.

I've added the issue at http://issues.openkm.com/view.php?id=1676

Do you consider could be some other features in same way, I only added go to some folder and refresh operation, do you consider could be others ?

Other question is when this events must be fired ... after executing workflow ( submit button )?, before seems has no sence ?

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.