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
15 replies
Subscribers
8 subscribers
Views
7086 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
How do we get the next task Id of a User Input Task. This has to be entered in t
aneeshv713
over 10 years ago
How do we get the next task Id of a User Input Task. This has to be entered in the Send Email Smart Service which is triggered before the User Input Task? Is there any such Out Of The Box function?...
OriginalPostID-114894
OriginalPostID-114894
Discussion posts and replies are publicly visible
0
Eduardo Fuentes
Appian Employee
over 10 years ago
This line gives you an array of TaskSummaryObjects because getResults() returns an Array of Objects and TaskSummary[] is by inheritance an Array of Objects so the cast is allowed at compilation time and works at runtime
TaskSummary[] currentTasksForProcess = (TaskSummary[])currentTasksForProcessResultPage.getResults();
this gives you a list of details for each task. You can then iterate over these objects and get the task ID which can be stored in a Long[] array.
Here's an example. In the example I'm finally storing all the task IDs within the varaible currentTasksIdsForProcessArray
ResultPage currentTasksForProcessResultPage = pes.getCurrentTasksForProcess(processId, type, startIndex, batchSize, sortBy, sortOrder);
TaskSummary[] currentTasksForProcess = (TaskSummary[])currentTasksForProcessResultPage.getResults();
List<Long> currentTasksIdsForProcessList = new ArrayList<Long>();
for (TaskSummary taskSummary : currentTasksForProcess) {
currentTasksIdsForProcessList.add(taskSummary.getId());
}
Long[] currentTasksIdsForProcessArray = currentTasksIdsForProcessList.toArray(new Long[0]);
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
aneeshv713
over 10 years ago
This piece of code is giving me an empty array?
Long[] currentTasksIdsForProcessArray = new Long[100];
TaskSummary[] taskResults = new TaskSummary[100];
ProcessExecutionService processExecutionService = ServiceLocator.getProcessExecutionService(sc);
try {
ResultPage resultPage;
resultPage = processExecutionService.getCurrentTasksForProcess(processID, com.appiancorp.suiteapi.process.ProcessExecutionService.UNATTENDED_AND_ATTENDED_TASKS, 1, 10, TaskSummary.SORT_BY_ID, Constants.SORT_ORDER_ASCENDING);
taskResults = (TaskSummary[])resultPage.getResults();
List<Long> currentTasksIdsForProcessList = new ArrayList<Long>();
for (TaskSummary taskSummary : taskResults)
{
currentTasksIdsForProcessList.add(taskSummary.getId());
}
System.out.println("Task IDs Array is -->"+currentTasksIdsForProcessList);
currentTasksIdsForProcessArray = currentTasksIdsForProcessList.toArray(new Long[100]);
System.out.println("Task IDs are -->"+currentTasksIdsForProcessArray);
} catch (InvalidProcessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (PrivilegeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return currentTasksIdsForProcessArray;
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
aneeshv713
over 10 years ago
Ok resolved the error.
processExecutionService.getCurrentTasksForProcess(processID, com.appiancorp.suiteapi.process.ProcessExecutionService.UNATTENDED_AND_ATTENDED_TASKS, 0, 10, TaskSummary.SORT_BY_ID, Constants.SORT_ORDER_ASCENDING);
Start Index should have been from 0 and not 1.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Eduardo Fuentes
Appian Employee
over 10 years ago
That's correct, at the API level arrays follow the Java convention of being 0-based indexed arrays. Only in the UI Appian arrays (not Java arrays) will be 1-based
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Pablo Ramos Clemente
over 5 years ago
in reply to
Eduardo Fuentes
Hola Eduardo,
I have a similary problem, but I need retrieve the details for each input of the Task. Is possible to do it without java code?
Im relatively new in Appian and I still dont control the java plugins, so im trying to do it only with Appian code and functions.
I have reached the point of recovering the instances of my tasks in a grid, and get the "id" of the task that I select. But I dont know how to access the inputs task details using this "id".
Thanks for your time!
Pablo.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
<