Stop a process instance

Hi,

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

My question:

  1. Where to put this script? (In submit button(action)?)
  2. If putted in submit button(action), what is the return value? Should i take value of that script and put it in variable?

Thank you

Hi did u get a solution to this?please let me me how to cancel a process with cancel button

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.

Best Regards

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?

Hi @haris.subasic,

Yes, i want to clear the entire process instance. The reasons is:

  1. Let says a client start a task and we called it Register New Bank Beneficiary
  2. Then the client start filling necessary data in that task form
  3. Suddenly, the client realize that’s not the task he/she intend to do
  4. He/she might can simply close the current tab or choose to start new task in portal
  5. The problem is, if i do not provide proper termination button (the client simply close current tab), the task will be dangling in Task Tab (Bonita Portal) and if i’ve a lot of user who practices this, the list will be long and irritating.
  6. That way i need to terminate the entire process instance so the client wont be having a long list of pending task sir.

Did u’ve any idea/solution that can solve this.

Thank in advance sir