Is it possible to suspend a task via process portal in IBM BPM 8.5.6. In the 6.2 version we were able to do this via inbox or saved searches. However the new saved searches doesn't support this? Is there a way to do this?
In v8.5 there is nothing like suspending a task from process portal. Although we can suspend a task from Admin Console .
Moreover if you want to suspend it from process portal , you can try the below way:
create a HS , having a text box for accepting PID of the process.
Use JS API , to suspend the Task for the provided PID.
var id = tw.local.pid ;
tw.system.findProcessInstanceByID(id).suspend() ;
Expose this human service as a Startable Service to the intented users.
provide the PID which you want to suspend .
As Jyoti Yadav already stated, you can suspend a task via Javascript API.
An alternate way would be using the /ProcessAdmin page. After logging in you choose the tab "Process Inspector" from the top of the page and search for your instances:
This would be a less flexible, but more human approachable way of suspending a task.
You can not suspend a task, you can suspend the instance.
This is OK if all tasks are sequential, but what if you have parallel tasks and you want to suspend only one of them.
A great alternative that i used is:
assign that task to the system user (bpmadmin, wasadmin, celladmin, deadmin,.... whatever you named it), then your instance is still active but it can not be completed until you reassign it back to a user and it finishes it.
This way you can create tasks now, and with a timer you can assign them to a user/group at a specified time.
The code i used:
tw.system.findTaskByID("123456").reassignTo("bpmadmin");
to assign it to the system user so no one can see it,
then in the timer script:
tw.system.findTaskByID("123456").reassignBackToRole();
to assign it back to the group to be executed.
You can either suspend them through the Process Inspector or via REST Api calls that BPM provides. URL can be :
https://baseroot:9443/bpmrest-ui/BPMRestAPITester/index.jsp
In answer to the follow up question, you can put it in the administration portal by exposing it as an "administration service" instead of a "human service".
https://ip:port/rest/bpm/wle/v1/process/xx?action=suspend&parts=all (put)
and
https://ip:port/rest/bpm/wle/v1/task?action=cancel&taskIDs=? (put)
You can refer to the API document of V 8.5.6 for task suspension and then use your own task ID to drop the API suspension task
Related
I am considering using Hangfire https://www.hangfire.io to replace an older home-grown scheduling ASP.NET web site/app.
I have created a simple test project using Hangfire. I am able to start the project with Hangfire, submit (in code) a couple of very simple single and recurring tasks, view the dashboard, etc.
I'm looking for more suggestions for creating a little more complex code (and classes) for tasks to be scheduled, and I have a question about what happens with permanently scheduled tasks when re-publishing a Hangfire site to production.
I have read some of the documentation on the Hangfire site, reviewed the 2 tutorials, scanned the Hangfire forums, and searched StackOverflow and the web a bit. A lot of what I have seen shows you how to schedule something very simple (like Console.WriteLine), but nothing more complex. The "Highlighter" tutorial was useful, but that essentially shows how to schedule a single instance of a (slightly longer-running) task in response to an interactive user input. I understand how useful that can be, but I'm more interested in recurring tasks that are submitted and then run every day (or every hour, etc.) and don't need to be submitted again. These tasks could be for something like sending a batch of emails to users each night, batch processing some data, importing a nightly feed of external data, periodically calling a web service to perform some processing, etc.
Is there any sample code available that shows some examples like this, or any guidance on the most appropriate approach for structuring such code in an interface and class(es)?
Secondly, in my case, most of the tasks would be "permanent" (always existing as a recurring task). If I set up code to add these as recurring tasks shortly after starting the Hangfire application in production, how should I handle it when publishing updates to production (when this same initialization would run again)? Should I just call "AddOrUpdate" with the same ID and Hangfire will take care of it? Should I first call "RemoveIfExists" and then add the recurring task again? Is there some other approach that should be used?
One example would be a log janitor, which would run every weekday # 5:00PM to remove logs that are older than 5 days.
public void Schedule()
{
RecurringJob.AddOrUpdate<LogJanitor>(
"Janitor - Old Logs",
j => j.OnSchedule(null),
"0 17 * * 1,2,3,4,5",
TimeZoneInfo.FindSystemTimeZoneById("CST"));
}
Then we would handle it this way
public void OnSchedule(
PerformContext context)
{
DateTime timeStamp = DateTime.Today.AddDays(-5);
_logRepo.FindAndDelete(from: DateTime.MinValue, to: timeStamp);
}
These two methods are declared inside LogJanitor class. When our application starts, we get an instance of this class then call Schedule().
When using Google Cloud Tasks, how can i prematurely run a tasks that is in the queue. I have a need to run the task before it's scheduled to run. For example the user chooses to navigate away from the page and they are prompted. If they accept the prompt to move away from that page, i need to clear the queued task item programmatically.
I will be running this with a firebase-function on the backend.
Looking at the API for Cloud Tasks found here it seems we have primitives to:
list - get a list of tasks that are queued to run
delete - delete a task this is queued to run
run - forces a task to run now
Based on these primitives, we seem to have all the "bits" necessary to achieve your ask.
For example:
To run a task now that is scheduled to run in the future.
List all the tasks
Find the task that you want to run now
Delete the task
Run a task (now) using the details of the retrieved task
We appear to have a REST API as well as language bound libraries for the popular languages.
We have a task that was created in IBM BPM and assigned to a Group.
In case someone from my Group has claimed it, how do I find which user of the group claimed the task?
Thanks,
Bharath
You may use Process Inspector application at /ProcessInspector with a user with administrative privileges.
You may search for and locate your process instance, and then locate the task you're interested in at details panel at the right-hand side. If the task is not yet claimed, you'll see the group name here, or if it's claimed by someone in that group you'll see that user's name.
You can get this info from the REST APIs. If you know the Process ID you can use the task summary REST API: http://host_name:port_number/rest/bpm/wle/v1/process/<process_id>/taskSummary/
Or if you know the Task ID you can use the Task Details REST API: http://host_name:port_number/rest/bpm/wle/v1/task/<task_id>?parts=all
You can test using the IBM BPM REST Test Tool: http://host_name:port_number/bpmrest-ui
How to get the user who initiated the process in IBM BPM 8.5. I want to reassign my task to the user who actually initiated the process. How it can be achieved in IBM BPM?
There are several ways to get that who initiated a Task , But who initiated a process Instance is somewhat different.
You can perform one out of the following :
Add a private variable and assign it tw.system.user_loginName at the POST of start. you can access that variable for user who initiated the process.(It will be null or undefined for the scenario if task is initiated by some REST API or UCA.)
Place a Tracking group after Start event . Add a input variable to it as username , assign it a value same as tw.system.user_loginName. So whenever Process is started entry will be inserted to DB Table.You can retrieve this value from that view in PerformanceDB.
Also there might be some table ,logging the process Instances details , where you can find the user_id directly.
I suggest you to look in getStarter() method of ProcessInstanceData API.
Official Documentation on API
This link on IBM Developerworks should help you too: Process Starter
Unfortunately there's not an Out Of The Box way to do this - nothing is recorded in the Process Instance that indicates "who" started a process. I presume this is because there are many ways to launch a process instance - from the Portal, via a Message Event, from an API call, etc.
Perhaps the best way to handle this is to add a required Input parameter to your BPD, and supply "who" started the process when you launch it. Unfortunately you can't supply any inputs from the OOTB Portal "New", but you can easilty build your own "launcher".
If you want to route the first task in process to the user that started the process the easiest approach is to simply put the start point in the lane, and on the activity select routing to "Last User In Lane". This will take care of the use case for you without requiring that you do the book keeping to track the user.
Its been a while since I've implemented this, so I can't remember if it will work elegantly if you have system steps before the first task, but this can easily be handled by moving the system steps into the human service to be executed as part of that call, rather than as a separate step in the BPD.
Define variable as string type and using script task to define the login user that use this task and assign it to your defined variable to keep to you in all of the process as initiator of the task.
You can use this line of code to achieve the same:
tw.system.user_loginName
I have an Activity( waiting for an approval ) that contains a WhileActivity. In the while activity I want to read the value of an argument - if it returns true I execute I continue with workflow execution, otherwise I stop the hanging the executing till the argument value turns true
How can I do this - for a while or other activities - ?
Thank you
If the value you are waiting on is being changed by another activity you can use a TrackingParticipant to watch for the value changing and when that happens resume a bookmark to notify your waiting activity.
Sounds more like your requirements would be better served by a State Machine workflow.
Okay, so you don't want to use a State Machine workflow. So, here's how you do it.
You have to create a custom Activity that is used in conjunction with a Workflow Extension. An Extension is just an object that can be accessed by your Activities as the workflow executes and allows your Activities to communicate with the classes that are executing the workflow.
Your custom Activity must be able to create a Bookmark and offload the Workflow. It does this while you wait for the correct value from your Extension. You don't need to do this in any While Activity loop. You just do the following
Get your Extension
Get the current value you are evaluating on
If you aren't happy, create a bookmark
When the bookmark resumes, go to step 1.
If you are happy, continue execution.