Java API; how to retrieve the status of a task

Document ID : KB000090001
Last Modified Date : 14/04/2018
Show Technical Document Details
Issue:
Java API; how to retrieve the status of a task
Resolution:

Please find below an Example how to retrieve the status of a task based by its RunID:

TaskDetails detail = new TaskDetails(runID);
detail.setArchiveDetail();
con.sendRequestAndWait(detail);
String statusMessage = details.findByName(uc4.getSessionInfo().getTranslator().messageWithoutType(4001172));
String activationTimeAsString = details.findByName(uc4.getSessionInfo().getTranslator().messageWithoutType(4001430));
String startTimeAsString = details.findByName(uc4.getSessionInfo().getTranslator().messageWithoutType(4001431));
String endTimeAsString = details.findByName(uc4.getSessionInfo().getTranslator().messageWithoutType(4001432));
/* Repeat for the other parameters */

// Get used variables
String objectVariableText = uc4.getSessionInfo().getTranslator().messageWithoutType(4000055);
Iterator<DetailGroup> it = details.groupIterator();
while (it.hasNext()) {
DetailGroup group = it.next();

if (group.getName().equals(objectVariableText)) {
Properties variables = group.getProperties();
for (Entry<Object, Object> entry : variables.entrySet()) {
System.out.println("variable name=" + entry.getKey() + " value = " + entry.getValue());
}
}
}

// Note: The status code of the execution needs to be retrieved by translating the statusMessage
int statusCode = uc4.getSessionInfo().getTranslator().reverse(statusMessage, 1000, 2000);