Skip to main content
williamm0010
June 27, 2022
Solved

Cancel Process Smart Service

  • June 27, 2022
  • 11 replies
  • 0 views

We have a request I am working on and can not figure out.  A user does something in the system adding records to a table, a process task is started so another person can verify and if approved it goes ahead and approves it, if they reject it with a comment it is sent back to the original person to look at.

They now want the ability so the original request can be deleted if put in in error, we have that part working.  But we are wanting to use the Cancel Process Smart Service to cancel the process task.  It is wanting a process id and can not figure out how to get the process id for the first entry when the user inputs the data.

So the user inputs the data and the process is created for the task.   But then a little bit later the user goes back in and deletes the data they input, it will only allow them to do this if it has not been approved yet.  The process task that was created is still there and now need to cancel it.

Any idea on how to get or find the process id for the task that was created so when the user deletes what they did it can cancel the process task also?

Thank you

Best answer by mikes0011

I usually recommend, if at all possible, allowing a user to cancel their own task (though i'm a little unclear if this is what you mean here), using a "cancel" button on-form which will route directly to a terminate node in that process.

If you really do need to cancel the process externally, you can access the process ID in at least 2 common ways.  The most common is probably by use of the Query Process Analytics rule called in the context of the process model in question, filtered down by some other identifying info, which can return the process ID as well as all kinds of other metadata depending on what Process Report you use to source the data from.

The second most common way (and easiest, if you set it up in advance), is to have the original process store its own process instance ID to the database shortly after initialization, i.e. in a dedicated column you set up in an existing table & CDT, as in something that specially handles that process.

11 replies

mikes0011
mikes0011Answer
Brainy
June 27, 2022

I usually recommend, if at all possible, allowing a user to cancel their own task (though i'm a little unclear if this is what you mean here), using a "cancel" button on-form which will route directly to a terminate node in that process.

If you really do need to cancel the process externally, you can access the process ID in at least 2 common ways.  The most common is probably by use of the Query Process Analytics rule called in the context of the process model in question, filtered down by some other identifying info, which can return the process ID as well as all kinds of other metadata depending on what Process Report you use to source the data from.

The second most common way (and easiest, if you set it up in advance), is to have the original process store its own process instance ID to the database shortly after initialization, i.e. in a dedicated column you set up in an existing table & CDT, as in something that specially handles that process.

The Expression Guru
williamm0010
June 27, 2022

Here is what it needs to do, lets say user 1 goes in and inputs the data and it creates the process task for it to be reviewed.  But then user 2 goes in and sees it was input wrong so they delete what user 1 put in.  Once is deletes what user 1 put in it needs to cancel that original process task that was created.  What worries me about using the user who created is this, what if the user does three different entries, and it creates three process tasks.  If I try to remove it by the person who submitted it would it remove all three even though it just needs to remove one.

mikes0011
Brainy
June 28, 2022
it needs to cancel that original process task

What "original process task" are you referring to here?  By the time User 1 has submitted their information for review, their "task" no longer exists as it's been submitted.  If you're talking about the process belonging to the Reviewer, why wouldn't that review task be contained in the same original parent process thread?  In that case all you'd need to do is terminate that process.

The Expression Guru