get latest runid using javaAPI

Discussion created by SamahSohrab607228 on Jan 2, 2018
Latest reply on Jan 4, 2018 by brendan_sapience_automic
Any one have experience with getting the latest runid of an object via the java api?

Currently, I'm using 
public int getLatestRunID(@RequestParam() String taskName) {
    UC4ObjectName objName = new UC4ObjectName(taskName);
    LatestReport req = new LatestReport(objName);
    return req.latestRunID();
but that fails when the job has been activated, but not started because there is no report to be returned.

I was thinking of using the ObjectStatistics function
ObjectStatistics jobStats = new ObjectStatistics(uc4Name, maxResults);
but I wasn't sure if I would 100% be guaranteed that this would be in descending activation order. So then I'd have to bring back multiple results and check the activation date before getting the runid.

Any other thoughts?