<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: getBusinessRuntime() from the last running case</title><link>https://answers.axonivy.com/questions/1842/getbusinessruntime-from-the-last-running-case</link><description>&lt;p&gt;Hi,
does anybody can help me with the getBusinessRuntime() function? It returns null because of the running state of the Task and I do not know how I can get the business runtime from the last running case or from a certain case with the state done. &lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/1842/getbusinessruntime-from-the-last-running-case" rel="self"></atom:link><language>en</language><lastBuildDate>Tue, 28 Jun 2016 14:00:58 -0400</lastBuildDate><item><title>Comment by Reguel Wermelinger on Gabriele's answer</title><link>https://answers.axonivy.com/questions/1842/getbusinessruntime-from-the-last-running-case#1851</link><description>&lt;p&gt;I agree, the query from reto only works with 6.2 which will be released this week.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reguel Wermelinger</dc:creator><pubDate>Tue, 28 Jun 2016 14:00:58 -0400</pubDate><guid>https://answers.axonivy.com/questions/1842/getbusinessruntime-from-the-last-running-case#1851</guid></item><item><title>Answer by Gabriele</title><link>https://answers.axonivy.com/questions/1842/getbusinessruntime-from-the-last-running-case/1850</link><description>&lt;p&gt;Hi Reto,
First of all thank's for your help.
You probably don't use the 6.1 Designer Version. Your query doesn't work because of the executor().
It tooks me a lot of time to find a way to get the runtime of the last running case. See below.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import ch.ivyteam.ivy.workflow.CaseState;
import ch.ivyteam.ivy.workflow.query.CaseQuery;
import ch.ivyteam.ivy.workflow.ICase;

CaseQuery caze = CaseQuery.create().where().name().isEqual("Laufzeit").and().state().isEqual(CaseState.DONE);
Number count = ivy.wf.getCaseQueryExecutor().getCount(caze);
ivy.log.info("count "+count); //Zähler prüfen
if (count != 0){
    Recordset erg = ivy.wf.getCaseQueryExecutor().getRecordset(caze.groupBy().businessRuntime());
    ivy.log.info("letzteRuntime "+erg.getField(count-1,0));
}
&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Gabriele</dc:creator><pubDate>Tue, 28 Jun 2016 11:00:48 -0400</pubDate><guid>https://answers.axonivy.com/questions/1842/getbusinessruntime-from-the-last-running-case/1850</guid></item><item><title>Answer by Reto Weiss</title><link>https://answers.axonivy.com/questions/1842/getbusinessruntime-from-the-last-running-case/1844</link><description>&lt;p&gt;Use the classes &lt;code&gt;TaskQuery&lt;/code&gt; or &lt;code&gt;CaseQuery&lt;/code&gt; to query for tasks and cases that have already been done. And then call the method &lt;code&gt;getBusinessRuntime&lt;/code&gt;() on the returning results.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import ch.ivyteam.ivy.workflow.CaseState;
import ch.ivyteam.ivy.workflow.query.CaseQuery;
import ch.ivyteam.ivy.workflow.ICase;

ICase caze = CaseQuery.create().where().name().isEqual("MyCase").and().state().isEqual(CaseState.DONE).executor().firstResult() as ICase;
caze.getBusinessRuntime();
&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reto Weiss</dc:creator><pubDate>Fri, 24 Jun 2016 14:45:18 -0400</pubDate><guid>https://answers.axonivy.com/questions/1842/getbusinessruntime-from-the-last-running-case/1844</guid></item></channel></rss>