<?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=560" rel="self" type="application/rss+xml" />
<item>
<title><![CDATA[AX 2012: Ändern einer Standardfinanzdimension (DefaultDimension) eines Datensatzes]]></title>
<description><![CDATA[
<p>Der nachstehende Job demonstriert, wie man den Wert einer Dimension (im Beispiel wird die Dimension <em>Kostenstelle </em>eines Debitors ge&auml;ndert) innerhalb der Standardfinanzdimensionen eines Datensatzes per Code austauschen kann. Auf diese Art &amp; Weise k&ouml;nnen auch einzelne Dimensionswerte entfernt werden.
</p>


<pre class="pre_blog_axcode">
static void changeDimensionValue(Args _args)
{
    DimensionAttributeValueSetStorage dimensionAttributeValueSetStorage;
    DimensionAttribute dimensionAttribute;
    CustTable custTable = CustTable::find(&quot;US-014&quot;);
    DimensionValue oldDimensionValue;
    DimensionValue newDimensionValue = &quot;011&quot;;
    DimensionDefault newDimensionDefault;

    #define.dimensionName(&quot;CostCenter&quot;)

    DimensionValue getDimensonValue(DimensionDefault _dimensionDefault)
    {
        DefaultDimensionView defaultDimensionView;
        select firstonly DisplayValue
        from defaultDimensionView
        where defaultDimensionView.Name == #dimensionName
            &amp;&amp; defaultDimensionView.DefaultDimension == _dimensionDefault;

        return defaultDimensionView.DisplayValue;
    }

    // Get current value
    oldDimensionValue = getDimensonValue(custTable.DefaultDimension);

    // Build DimensionAttributeValueSetStorage
    dimensionAttributeValueSetStorage = DimensionAttributeValueSetStorage::find(custTable.DefaultDimension);
 
    // Remove old dimension value
    dimensionAttribute = DimensionAttribute::findByName(#dimensionName);
    dimensionAttributeValueSetStorage.removeDimensionAttributeValue(
        DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute, oldDimensionValue).RecId);
 
    // Set new dimension value
    if(newDimensionValue != &quot;&quot;)
    {
        dimensionAttribute = DimensionAttribute::findByName(#dimensionName);
        dimensionAttributeValueSetStorage.addItem(
            DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute, newDimensionValue));
    }
 
    newDimensionDefault = dimensionAttributeValueSetStorage.save();

    ttsbegin;
    custTable.selectForUpdate(true);
    custTable.DefaultDimension = newDimensionDefault;
    custTable.update();
    ttscommit;
}
</pre>


<p>Screenshot vor der &Auml;nderung
</p>


<p><a href="http://www.schweda.net/pictures/blogpics/ax2012_changecostcentercustomerold.jpg" rel="lightbox" target="_blank"><img alt="Screenshot" height="93" src="http://www.schweda.net/pictures/blogpics/tb_ax2012_changecostcentercustomerold.jpg" title="Screenshot" width="465" /></a>
</p>


<p>Screenshot nach der &Auml;nderung
</p>


<p><a href="http://www.schweda.net/pictures/blogpics/ax2012_changecostcentercustomernew.jpg" rel="lightbox" target="_blank"><img alt="Screenshot" height="93" src="http://www.schweda.net/pictures/blogpics/tb_ax2012_changecostcentercustomernew.jpg" title="Screenshot" width="465" /></a>
</p>]]></description>
<category>Microsoft Dynamics AX (Axapta)</category>
<pubDate>Sat, 07 Feb 2015 17:06:00 +0100</pubDate>
<link>https://www.schweda.net/blog_ax.php?bid=560</link>
<comments>https://www.schweda.net/blog_ax.php?bid=560</comments>
<guid isPermaLink="true">https://www.schweda.net/blog_ax.php?bid=560</guid>
<author>heinz.schweda@schweda.net (Heinz Schweda)</author>
<wfw:commentRss>https://www.schweda.net/blog_ax.php?bid=560</wfw:commentRss>
</item>
</channel>
</rss>	
