Products | Versions |
---|---|
TIBCO EBX | All versions from 5.8.0. |
Please see links in "reference" section.
In this article we will explain how to launch a workflow from a user service without display, namely a UserServiceExtended.
You can use this method to launch a workflow:
We will use a workflow publication named "BasicWorkflow" and configured it to automatically open the first step in its model configuration:
Compared to a UserService, the UserServiceExtended has one more method, initialize, that is called on service creation, and allows to perform without-display operations before display.
Restrictions:
Association
or AssociationRecord
are not supported and should not implement this interface.The context of the initialize method allows us to retrieve the entity selection, and pass it as as a data context variable when launching the workflow.
In our example, everything will be done without display, from the worfklow engine retrieval to the redirection to the first work item, so we only need to implement the initialize() method.
At the end of the workflow, the user will be redirected to the inbox view.
If you want to act on the redirection, you will have to implement a more complex solution with the UserService API.
Please see article: Launch a workflow inside a UserService and redirect to the initial selection.
public UserServiceEventOutcome initialize(UserServiceInitializeContext<RecordEntitySelection> aContext) { try { Repository repository = aContext.getRepository(); Session session = aContext.getSession(); // Retrieve the process launcher of the "BasicWorkflow" workflow WorkflowEngine engine = WorkflowEngine.getFromRepository(repository,session); ProcessLauncher launcher = engine.getProcessLauncher(PublishedProcessKey.forName( "BasicWorkflow" )); // Retrieve the selected record and set its ID as a data context variable Adaptation selectedRecord = aContext.getEntitySelection().getRecord(); String selectedRecordID = selectedRecord.getString(Path.parse( "./id" )); launcher.setInputParameter( "selectedRecord" , selectedRecordID); // Launch the workflow instance and get the work item key ProcessLauncherResult result = launcher.launchProcessWithResult(); WorkItemKey workItemKey = result.getWorkItemKey(); // At the end, close the service and redirect to the next work item return UserServiceNext.nextWorkItem(workItemKey, true ); } catch (OperationException e) { return null ; } } |
User services documentation:
Knowledge base article:
UserServiceExtended java documentation: https://docs.tibco.com/pub/ebx/5.9.7/doc/html/en/Java_API/com/orchestranetworks/userservice/UserServiceExtended.html