<?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://www.schweda.net/blog_rss.php?bid=494" rel="self" type="application/rss+xml" />
<item>
<title><![CDATA[Erstellen einer Entität - beispielsweise eines Debitoren - per Code unter Verwendung von AX<Table>-Klassen]]></title>
<description><![CDATA[
<p>Folgender Job soll veranschaulichen, wie man unter Verwendung von sog. <strong>AX&lt;Table&gt;-Klassen</strong> Entit&auml;ten in Dynamics AX per Code anlegen kann, ohne dabei - wie in <a href="http://www.schweda.net/blog_ax.php?bid=493" target="_self" title="Erstellen einer Entität per Code">diesem Beitrag</a> beschrieben - direkt in die Tabellen zu schreiben.<br />
<br />
Solche AX&lt;Table&gt;-Klassen stehen bereits f&uuml;r zahlreiche Tabellen von Haus aus zu Verf&uuml;gung und es ist m&ouml;glich, sich jederzeit f&uuml;r weitere Tabellen solche Klassen generieren zu lassen (<a href="http://www.schweda.net/blog_ax.php?bid=495" target="_self" title="Generieren einer AX&lt;Table&gt;-Klasse">siehe hier</a>).<br />
<br />
<strong>Vorteile</strong>:
</p>


<ul>
	
<li>Pflichtfelder werden gepr&uuml;ft
</li>
	
<li>Datensatz wird initalisiert (d.h. die initValue() wird aufgerufen)
</li>
	
<li>Feldinhalten werden gepr&uuml;ft
</li>

</ul>


<p><strong>Nachteile:</strong>
</p>


<ul>
	
<li>Bei Feld&auml;nderung wird die Logik in der modifiedField() nicht aufgerufen
</li>

</ul>


<pre class="pre_blog_axcode">
static void CreateCustomerAXClass(Args _args)
{
    AxCustTable axCustTable;
    AxDirPartyTable AxDirPartyTable;
    CustTable CustTable;
    DirPartyTable DirPartyTable;

    AccountNum accountNum     = &quot;4711&quot;;
    Name name                 = &quot;Debitor 4711&quot;;
    currencyCode currencyCode = &quot;EUR&quot;;
    custGroupId custGroupId   = &quot;DINL&quot;;
    taxGroup taxGroup         = &quot;DINL&quot;;
    languageId languageId     = &quot;de-AT&quot;;

    ttsBegin;

    // Create or update Customer
    axCustTable = axCustTable::construct();
    axCustTable.validateInput(true);    
    axCustTable.continueOnError(true);  // Validate fields without stopping error
    
    CustTable = CustTable::find(accountNum, true);
    if(CustTable)
    {
        axCustTable.custTable(CustTable);   // Don&#39;t use this for new records to get initValue() called
    }

    axCustTable.parmAccountNum(accountNum);
    axCustTable.parmCustGroup(custGroupId);
    axCustTable.parmTaxGroup(taxGroup);
    axCustTable.parmCurrency(currencyCode);
    
    axCustTable.save();

    // Create or update Global address book
    AxDirPartyTable = AxDirPartyTable::construct();
    AxDirPartyTable.validateInput(true);
    AxDirPartyTable.continueOnError(true);  // Validate fields without stopping error
    
    DirPartyTable = DirPartyTable::findRec(axCustTable.custTable().Party, true);
    if(DirPartyTable)
    {
        AxDirPartyTable.dirPartyTable(DirPartyTable);
    }

    AxDirPartyTable.parmName(name);
    AxDirPartyTable.parmLanguageId(languageId);
    
    AxDirPartyTable.save();

    ttsCommit;
}
</pre>]]></description>
<category>Microsoft Dynamics AX (Axapta)</category>
<pubDate>Tue, 12 Nov 2013 15:27:00 +0100</pubDate>
<link>https://www.schweda.net/blog_ax.php?bid=494</link>
<comments>https://www.schweda.net/blog_ax.php?bid=494</comments>
<guid isPermaLink="true">https://www.schweda.net/blog_ax.php?bid=494</guid>
<author>heinz.schweda@schweda.net (Heinz Schweda)</author>
<wfw:commentRss>https://www.schweda.net/blog_ax.php?bid=494</wfw:commentRss>
</item>
</channel>
</rss>	
