Stop a process instance
I'm trying to do abort button (terminate the task incessantly) if user are accidentally select wrong task to do. I've been looking up in Bonita Documentation and found this:
final ProcessAPI processAPI = TenantAPIAccessor.getProcessAPI(apiSession); processAPI.cancelProcessInstance(processInstanceID); - See more at: http://documentation.bonitasoft.com/comment/reply/225#sthash.x1ImLKY2.dpuf
- Where to put this script? (In submit button(action)?)
- If putted in submit button(action), what is the return value? Should i take value of that script and put it in variable?
I think it would be good to clarify your needs a little bit. When you say "accidentally select wrong task", why do you need to "abort" it? Shouldn't they just get back to their task list and leave the task for someone else (or they will select it later themselves)? The peace of code you quoted cancels the entire process instance. Is this really what you want to do?
I have a solution, simpler than implementing a cancel button, which additionaly corresponds to our design best practices. You should define the 1st process form on the start event of the process. Then, if the end-user clicks on the process, visualizes the 1st form, even starts to fill-it-in and notices it is not the right process, he can go back to its task list and no process instance is created. Please come back to me to tell me if it fits your need.