<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: RuntimeException after destroying ivy case</title><link>https://answers.axonivy.com/questions/3844/runtimeexception-after-destroying-ivy-case</link><description>&lt;p&gt;Hi Ivyteam,&lt;/p&gt;
&lt;p&gt;We have a function to delete a list of cases base on dossierId:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    SecurityManagerFactory.getSecurityManager().executeAsSystem2(() -&amp;gt; {
        CaseQuery taskQuery = CaseQuery.create()
          .where().customVarCharField4().isEqual(dossierId);
        List&amp;lt;ICase&amp;gt; cases = Ivy.wf().getCaseQueryExecutor().getResults(taskQuery);
        cases.forEach(ICase::destroy);
    });
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After the case is destroyed successfully, the application is crashed because an exception&lt;/p&gt;
&lt;p&gt;IvyRuntimeException: Task '25' is no longer running. Maybe the task has been reseted or parked meanwhile.
    ELException: ch.ivyteam.util.IvyRuntimeException: Task '25' is no longer running. Maybe the task has been reseted or parked meanwhile.
    ContextAwareELException: javax.el.ELException: ch.ivyteam.util.IvyRuntimeException: Task '25' is no longer running. Maybe the task has been reseted or parked meanwhile.
    Error during rendering of html dialog 'ch.axonivy.desk.individual.customer1.DataGatheringPage'&lt;/p&gt;
&lt;p&gt;I am using Ivy 7.0.11. How can I overcome this exception?&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Cuong Nguyen&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/3844/runtimeexception-after-destroying-ivy-case" rel="self"></atom:link><language>en</language><lastBuildDate>Tue, 11 Jun 2019 05:22:56 -0400</lastBuildDate><item><title>Answer by Reguel Wermelinger</title><link>https://answers.axonivy.com/questions/3844/runtimeexception-after-destroying-ivy-case/3856</link><description>&lt;p&gt;the script just killed the task/case which owns the dialog(script activity) which runs the deletion script. So I'd start to fix this issue by filtering the current case:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;CaseQuery taskQuery = CaseQuery.create()
.where().customVarCharField4().isEqual(dossierId)
.and().caseId().isNotEqual(Ivy.wfCase().getId());
&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reguel Wermelinger</dc:creator><pubDate>Tue, 11 Jun 2019 05:22:56 -0400</pubDate><guid>https://answers.axonivy.com/questions/3844/runtimeexception-after-destroying-ivy-case/3856</guid></item><item><title>Comment by nvcuong01 on nvcuong01's question</title><link>https://answers.axonivy.com/questions/3844/runtimeexception-after-destroying-ivy-case#3855</link><description>&lt;p&gt;The issue was solved. Thank &lt;a href="https://answers.axonivy.com/users/17/reguel-wermelinger"&gt;&lt;a href="https://answers.axonivy.com/users/17/reguel-wermelinger"&gt;@Reguel Wermelinger&lt;/a&gt;&lt;/a&gt; for your help!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">nvcuong01</dc:creator><pubDate>Tue, 11 Jun 2019 05:21:14 -0400</pubDate><guid>https://answers.axonivy.com/questions/3844/runtimeexception-after-destroying-ivy-case#3855</guid></item><item><title>Comment by Reguel Wermelinger on nvcuong01's question</title><link>https://answers.axonivy.com/questions/3844/runtimeexception-after-destroying-ivy-case#3850</link><description>&lt;p&gt;in plain java: &lt;code&gt;ICase current = Ivy.wfCase();&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;therefore...&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;CaseQuery taskQuery = CaseQuery.create()
.where().customVarCharField4().isEqual(dossierId)
.and().caseId().isNotEqual(Ivy.wfCase().getId());
&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reguel Wermelinger</dc:creator><pubDate>Tue, 11 Jun 2019 04:36:13 -0400</pubDate><guid>https://answers.axonivy.com/questions/3844/runtimeexception-after-destroying-ivy-case#3850</guid></item><item><title>Comment by nvcuong01 on nvcuong01's question</title><link>https://answers.axonivy.com/questions/3844/runtimeexception-after-destroying-ivy-case#3847</link><description>&lt;p&gt;Thank &lt;a href="https://answers.axonivy.com/users/17/reguel-wermelinger"&gt;&lt;a href="https://answers.axonivy.com/users/17/reguel-wermelinger"&gt;@Reguel Wermelinger&lt;/a&gt;&lt;/a&gt; for your response. Could you clarify how to "filtering the current case"?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">nvcuong01</dc:creator><pubDate>Tue, 11 Jun 2019 04:06:19 -0400</pubDate><guid>https://answers.axonivy.com/questions/3844/runtimeexception-after-destroying-ivy-case#3847</guid></item><item><title>Comment by Reguel Wermelinger on nvcuong01's question</title><link>https://answers.axonivy.com/questions/3844/runtimeexception-after-destroying-ivy-case#3846</link><description>&lt;p&gt;sounds like your script just killed the task/case which owns the dialog(script activity) which runs the deletion script. So I'd start to fix this issue by filtering the current case.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reguel Wermelinger</dc:creator><pubDate>Tue, 11 Jun 2019 03:43:21 -0400</pubDate><guid>https://answers.axonivy.com/questions/3844/runtimeexception-after-destroying-ivy-case#3846</guid></item></channel></rss>