<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Persist first task using api</title><link>https://answers.axonivy.com/questions/1644/persist-first-task-using-api</link><description>&lt;p&gt;Hi all,
   at the Prozess start is possible to set in Workflow Mode "Persist task on creation". Is there any possibility to set this in script dynamically using API? We sometimes need it sometimes not.&lt;/p&gt;
&lt;p&gt;Karel Tauser&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/1644/persist-first-task-using-api" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 28 Jan 2016 15:20:14 -0500</lastBuildDate><item><title>Answer by Flavio Sadeghi</title><link>https://answers.axonivy.com/questions/1644/persist-first-task-using-api/1645</link><description>&lt;p&gt;Currently there is no explicit API. But as a workaround an operation could be peformed which requires a persistent case/task. E.g. by creating (and deleting) a note. &lt;/p&gt;
&lt;p&gt;To simplify the usage (and to hide the 'workaround') a helper class (located in the &lt;code&gt;src&lt;/code&gt; folder of the project) could fit.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;package wf;

import ch.ivyteam.ivy.environment.Ivy;
import ch.ivyteam.ivy.security.SecurityManagerFactory;
import ch.ivyteam.ivy.workflow.INote;

public final class TaskUtil {
    public static void persistCurrentTask() throws Exception {
        SecurityManagerFactory.getSecurityManager().executeAsSystem(() -&amp;gt; {
            INote note = Ivy.wfTask().createNote(Ivy.session(), TaskUtil.class.getName());
            Ivy.wfTask().deleteNote(note);
            return null;
        });
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Usage of the of the above method inside a script step:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;wf.TaskUtil.persistCurrentTask()
&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Flavio Sadeghi</dc:creator><pubDate>Thu, 28 Jan 2016 15:20:14 -0500</pubDate><guid>https://answers.axonivy.com/questions/1644/persist-first-task-using-api/1645</guid></item></channel></rss>