<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="https://www.schweda.net/style_feed.css" ?>
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    xmlns:atom="http://www.w3.org/2005/Atom"	
	xmlns:dc="http://purl.org/dc/elements/1.1/" > 
<channel>
    <title>schweda.net - Blog</title>
    <link>https://www.schweda.net/</link>
    <description>schweda.net - Blog - Blog-Beitraege</description>
    <language>de-at</language>
    <copyright>Copyright 2006-2026</copyright>
    <generator>schweda.net</generator>
    <managingEditor>heinz.schweda@schweda.net (Heinz Schweda)</managingEditor>
    <webMaster>heinz.schweda@schweda.net (Heinz Schweda)</webMaster>
    <category>Blog</category>
	<atom:link href="https://schweda.net/blog_rss.php?bid=638" rel="self" type="application/rss+xml" />
<item>
<title><![CDATA[SysOperation-Framework: Aufrufendes Formular aktualisieren]]></title>
<description><![CDATA[
<p>H&auml;ufig wird eine Funktion, die &uuml;ber das <strong>SysOperation-Framework</strong> abgebildet wurde, aus einem Formular heraus &uuml;ber eine Schaltfl&auml;che aufgerufen. Dabei hat man meist die Anforderung, da&szlig; die angezeigten Daten im Formular nach der Ausf&uuml;hrung aktualisiert werden sollen.
</p>


<p>Ich benutze daf&uuml;r gerne die folgende Logik. Diese geht davon aus, da&szlig; der Aufruf der Funktion &uuml;ber eine Schalfl&auml;che erfolgt ist und dadurch die <em>main()</em>-Methode getriggert wird.
</p>


<p>Die eigentliche Aktualisierug erfolgt &uuml;ber eine Sub-Methode und k&ouml;nnte wie folgt aussehen:
</p>


<pre class="pre_blog_axcode">
private void refreshCallingForm(args _args)
{
    FormRun callerFormRun;
    #Task

    if(_args &amp;&amp; _args.caller() &amp;&amp; _args.caller() is formRun)
    {
        callerFormRun = _args.caller();
        callerFormRun.task(#taskF5);
    }
}
</pre>


<p>Der Aufruf dieser Methode erfolgt in der erw&auml;hnten <em>main()</em>:
</p>


<pre class="pre_blog_axcode">
public static void main(Args _args)
{
    TutorialSysOperationController controller;
    SysOperationStartResult sysOperationStartResult;

    controller = new TutorialSysOperationController();
    controller.parmArgs(_args);
    controller.parmExecutionMode(
        SysOperationExecutionMode::Synchronous);

    sysOperationStartResult =
    controller.startOperation();

    controller.refreshCallingForm(_args);
}
</pre>


<h2>Denkbare Variationen der refreshCallingForm()
</h2>


<p>Statt der task()-Methode der Form k&ouml;nnte man auch Methoden der Formdatasource aufrufen.&nbsp;
</p>


<h3>Verwendung von ExecuteQuery()
</h3>


<p>Verwendet man die&nbsp;<em>executeQuery()</em> der jeweiligen FomDataSource, so gehen dabei etwaige Filter sowie der Datensatz-Fokus verloren.
</p>


<pre class="pre_blog_axcode">
private void refreshCallingForm(args _args)
{
    FormDataSource fds;
    
    if(_args &amp;&amp; 
       _args.record() &amp;&amp; 
       _args.record().isFormDataSource())
    {
        fds = _args.record().dataSource();
        fds.executeQuery();
    }
}
</pre>


<h3>Verwendung von ReSearch()
</h3>


<pre class="pre_blog_axcode">
private void refreshCallingForm(args _args)
{
    FormDataSource fds;
    
    if(_args &amp;&amp; 
       _args.record() &amp;&amp; 
       _args.record().isFormDataSource())
    {
        fds = _args.record().dataSource();
        fds.research(true);
    }
}
</pre>


<h3>Verwendung von ReRead()
</h3>


<p>Auch ein <em>ReRead()</em> w&auml;re denkbar, in diesem Fall w&uuml;rde aber nur der aktive Datensatz aktualisiert werden.
</p>


<pre class="pre_blog_axcode">
private void refreshCallingForm(args _args)
{
    if(_args &amp;&amp; 
       _args.record() &amp;&amp; 
       _args.record().isFormDataSource())
    {
        _args.record().reread();
    }
}

</pre>]]></description>
<category>Microsoft Dynamics AX (Axapta)</category>
<pubDate>Mon, 09 Apr 2018 20:38:00 +0200</pubDate>
<link>https://www.schweda.net/blog_ax.php?bid=638</link>
<comments>https://www.schweda.net/blog_ax.php?bid=638</comments>
<guid isPermaLink="true">https://www.schweda.net/blog_ax.php?bid=638</guid>
<author>heinz.schweda@schweda.net (Heinz Schweda)</author>
<wfw:commentRss>https://www.schweda.net/blog_ax.php?bid=638</wfw:commentRss>
</item>
</channel>
</rss>	
