Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
5 replies
Subscribers
5 subscribers
Views
2611 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
Plug-Ins
I am trying to get the active tasks of an instance using the below code. There i
Karthik
over 8 years ago
I am trying to get the active tasks of an instance using the below code. There is an active task at a process which is nested two levels from the parent process. And the below code is not capturing the active task that I am looking for. How can I get the tasks of a subprocess?
TaskSummary[] tss = (TaskSummary[]) pes.getCurrentTasksForProcess(
cddProcessId,
ProcessExecutionService.UNATTENDED_AND_ATTENDED_TASKS, 0,
Constants.COUNT_ALL, TaskSummary.SORT_BY_ASSIGNED_TIME,
Constants.SORT_ORDER_DESCENDING).getResults();
OriginalPostID-198760
OriginalPostID-198760
Discussion posts and replies are publicly visible
0
Carlos Santander
A Score Level 2
over 8 years ago
It seems like you'll need to iterate over the results of getSynchronousSubProcessesForProcess(...)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 8 years ago
@karthikeyans I would suggest you taking a look at 'getTasksWithStatusForProcesses' (https://forum.appian.com/suite/help/16.1/api/com/appiancorp/suiteapi/process/ProcessExecutionService.html#getTasksWithStatusForProcess-java.lang.Long-java.lang.Integer-boolean-int-int-java.lang.Integer-java.lang.Integer-) which gets the Task Summary in a recursive manner, as the function has got 'recursive_' as an argument. If this works for you, you don't need to do following:
1. Getting the synchronous and asynchronous subprocesses.
2. Iterating through the results obtained from above mentioned step to get the Task Summary.
If the above mentioned procedure doesn't work for you, you may do as follows:
1. Get the synchronous and asynchronous subprocesses. (This results in getting all the subprocesses at any level for a given process.)
For doing so, you can take a look at API functions namely 'getSynchronousSubProcessesForProcess' and 'getAsynchronousSubProcessesForProcess'. You can even take a look at the code of the 'Get All Synchronous sub-process ids' Shared Component at https://forum.appian.com/suite/tempo/records/type/components/item/i8BCLGOdlMUpdGVqT-RV7oRg74uEGJO5ycfrnwOlwsGCGUoJtFPYvtso82lOyOrLA/view/summary. (Please note that though Shared Component mentions 'Asynchronous', this component returns Synchronous and Asynchronous information.)
2. Get the Task Summary from the results obtained above.
Instead of iterating through the results obtained from above step, you can take a look at 'getTasksWithStatusForProcesses' to obtain the Task Summary with an array of process ids obtained from the above mentioned step. If this doesn't work for you, consider applying 'getCurrentTasksForProcess' in an iterative fashion over the processes obtained in the above mentioned step.
If you want to get on with the existing and OOTB features rather than building a plugin, you can do so by performing following steps:
1. Get the synchronous and asynchronous subprocesses for a given process using the plugin 'Get All Synchronous sub-process ids' at https://forum.appian.com/suite/tempo/records/type/components/item/i8BCLGOdlMUpdGVqT-RV7oRg74uEGJO5ycfrnwOlwsGCGUoJtFPYvtso82lOyOrLA/view/summary. The output of this plugin is an array of subprocess ids at any level for a given process.
2. Using the process ids obtained in the above mentioned step, get the tasks information by querying the analytics. (getportalreportdatasubset() before 7.8 and a!queryProcessAnalytics() from and above 7.8)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sayedh
over 8 years ago
Hi karthikeyans75,
You should have a look at the Task Smart Service plugin. It has function that returns the active tasks for a process; you can pass the parent process id and a boolean parameter that determines whether the function should look at child processes. Here is the relevant code:
@Function
public Long[] getActiveTaskIDsForProcess(ProcessExecutionService pes, @Parameter Long processID,
@Parameter(required = false) Boolean includeSubs) {
if (includeSubs == null) {
includeSubs = false;
}
Long[] idArray = new Long[0];
try {
ResultPage rp1 = pes.getTasksWithStatusForProcess(processID,
TaskSummary.TASK_STATUS_ASSIGNED, includeSubs, 0, Constants.COUNT_ALL,
TaskSummary.SORT_BY_ASSIGNED_TIME, Constants.SORT_ORDER_ASCENDING);
ResultPage rp2 = pes.getTasksWithStatusForProcess(processID,
TaskSummary.TASK_STATUS_ACCEPTED, includeSubs, 0, Constants.COUNT_ALL,
TaskSummary.SORT_BY_ASSIGNED_TIME, Constants.SORT_ORDER_ASCENDING);
idArray = new Long[rp1.getNumResults() + rp2.getNumResults()];
TaskSummary[] ts1 = (TaskSummary[]) rp1.getResults();
TaskSummary[] ts2 = (TaskSummary[]) rp2.getResults();
for (int i = 0; i < ts1.length; i++) {
idArray[i] = ts1[i].getId();
}
for (int i = 0; i < ts2.length; i++) {
idArray[i + ts1.length] = ts2[i].getId();
}
} catch (Exception e) {
LOG.error(e, e);
}
return idArray;
}
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Karthik
over 8 years ago
@All, Thanks for helping me out. I could get it worked using getTasksForProcess API and iterate through the resultset.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
vikask146
over 8 years ago
Can anyone of you suggest for any API to complete Task or other operation like Save/Cancel etc ?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel