<?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?bsid=4&amp;wdl=en" rel="self" type="application/rss+xml" />
<item>
<title><![CDATA[Filter a FormdataSource by financial dimensions]]></title>
<description><![CDATA[
<p>If you only want to display data records of a table that contain certain financial dimensions in a form, you can do this by overwriting the <em>init()</em> of the FormDataSource as follows:
</p>


<pre class="pre_blog_axcode">
public void init()
{
    super();
    
    SysQuery::addDimensionAttributeRange(salesTable_ds.query(),
                        salesTable_ds.name(),
                        fieldStr(Salestable, DefaultDimension),
                        DimensionComponent::DimensionAttribute,
                        &#39;1001&#39;,
                        &#39;CostCenter&#39;);    
}
</pre>


<p>You can also call <em>addDimensionAttributeRange()</em> multiple times, so you can filter for multiple dimensions simultaneously.
</p>


<p><em>clearDimensionRangesFromQuery()</em> removes such filters:
</p>


<pre class="pre_blog_axcode">
SysQuery::clearDimensionRangesFromQuery(salesTable_ds.query())
</pre>


<p>&nbsp;
</p>]]></description>
<category>Microsoft Dynamics AX (Axapta)</category>
<pubDate>Fri, 08 Mar 2019 18:18:00 +0100</pubDate>
<link>https://www.schweda.net/blog_ax.php?bid=661&amp;wdl=en</link>
<comments>https://www.schweda.net/blog_ax.php?bid=661&amp;wdl=en</comments>
<guid isPermaLink="true">https://www.schweda.net/blog_ax.php?bid=661&amp;wdl=en</guid>
<author>heinz.schweda@schweda.net (Heinz Schweda)</author>
<wfw:commentRss>https://www.schweda.net/blog_ax.php?bid=661&amp;wdl=en</wfw:commentRss>
</item>
<item>
<title><![CDATA[AX 2012: How to change the value of a default dimension of a record]]></title>
<description><![CDATA[
<p>The following job will give you an example, of how to change the value of a dimension within the default dimensions of a record (the example-job changes the value of the dimension <em>costcenter </em>of a customer). In this way and manner individual dimension values can be removed also.
</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 before job
</p>


<p><a href="http://www.schweda.net/pictures/blogpics/ax2012_changecostcentercustomerold.jpg" 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 after job
</p>


<p><a href="http://www.schweda.net/pictures/blogpics/ax2012_changecostcentercustomernew.jpg" 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&amp;wdl=en</link>
<comments>https://www.schweda.net/blog_ax.php?bid=560&amp;wdl=en</comments>
<guid isPermaLink="true">https://www.schweda.net/blog_ax.php?bid=560&amp;wdl=en</guid>
<author>heinz.schweda@schweda.net (Heinz Schweda)</author>
<wfw:commentRss>https://www.schweda.net/blog_ax.php?bid=560&amp;wdl=en</wfw:commentRss>
</item>
<item>
<title><![CDATA[AX 2012: Building a DefaultDimension/LedgerDimension]]></title>
<description><![CDATA[
<p>Below you&#39;ll find a code example of how to generate a RecId of type <strong>DefaultDimension</strong> for several dimensions.<br />
Subsequently, these DefaultDimension is combined with a main account to RecId of type <strong>LedgerDimension</strong>.
</p>


<pre class="pre_blog_axcode">
static void buildDefaultAndLedgerDimension(Args _args)
{
    DimensionAttributeValueSetStorage dimensionAttributeValueSetStorage;
    DimensionAttribute dimensionAttribute;
    DimensionAttributeValue dimensionAttributeValue;
    DimensionDefault dimensionDefault;
    LedgerDimensionAccount ledgerDimensionAccount;

    dimensionAttributeValueSetStorage = new DimensionAttributeValueSetStorage();

    // BusinessUnit
    dimensionAttribute = DimensionAttribute::findByName(&#39;BusinessUnit&#39;);
    if(dimensionAttribute)
    {
        dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute, &#39;069&#39;, false, true);
        dimensionAttributeValueSetStorage.addItem(dimensionAttributeValue);
    }

    // CostCenter
    dimensionAttribute = DimensionAttribute::findByName(&#39;CostCenter&#39;);
    if(dimensionAttribute)
    {
        dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute, &#39;010&#39;, false, true);
        dimensionAttributeValueSetStorage.addItem(dimensionAttributeValue);
    }

    // Department
    dimensionAttribute = DimensionAttribute::findByName(&#39;Department&#39;);
    if(dimensionAttribute)
    {
        dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute, &#39;024&#39;, false, true);
        dimensionAttributeValueSetStorage.addItem(dimensionAttributeValue);
    }
 
    dimensionDefault = dimensionAttributeValueSetStorage.save();

    // Merge main account and source dimension values and return RecId which can be used as ledgerDimension
    ledgerDimensionAccount = DimensionDefaultingService::serviceCreateLedgerDimension(DimensionStorage::getDefaultAccountForMainAccountNum(&quot;110110&quot;),
                                                                                      dimensionDefault);

    info(strFmt(&quot;Default dimension recId: %1&quot;, dimensionDefault));
    info(strFmt(&quot;DefaultDimension (Source RecId): %1 LedgerDimension (Merged RecId): %2&quot;, dimensionDefault, ledgerDimensionAccount));
}
</pre>]]></description>
<category>Microsoft Dynamics AX (Axapta)</category>
<pubDate>Sun, 14 Dec 2014 09:29:00 +0100</pubDate>
<link>https://www.schweda.net/blog_ax.php?bid=553&amp;wdl=en</link>
<comments>https://www.schweda.net/blog_ax.php?bid=553&amp;wdl=en</comments>
<guid isPermaLink="true">https://www.schweda.net/blog_ax.php?bid=553&amp;wdl=en</guid>
<author>heinz.schweda@schweda.net (Heinz Schweda)</author>
<wfw:commentRss>https://www.schweda.net/blog_ax.php?bid=553&amp;wdl=en</wfw:commentRss>
</item>
<item>
<title><![CDATA[AX 2012: Show RecId of type LedgerDimension as Display value]]></title>
<description><![CDATA[
<p>In the following code-example a record is selected from table LedgerJournalTrans, than the value of the field LedgerDimension respectively the field OffsetLedgerDimension is converted in the display value, which is display in a so called Segemented entry control.
</p>


<pre class="pre_blog_axcode">
static void GetLedgerDimensionDisplayValue(Args _args)
{
    DimensionStorage dimensionStorage;
    DimensionDisplayValue DimensionDisplayValue;
    ledgerJournalTrans ledgerJournalTrans = LedgerJournalTrans::findRecId(5637169330, false);
    
    // LedgerDimension
    dimensionStorage = DimensionStorage::findById(ledgerJournalTrans.LedgerDimension);
    DimensionDisplayValue = dimensionStorage.getComboDisplayValue();
    
    info(DimensionDisplayValue);   
     // OffsetLedgerDimension
    dimensionStorage = DimensionStorage::findById(ledgerJournalTrans.OffsetLedgerDimension);
    DimensionDisplayValue = dimensionStorage.getComboDisplayValue();
    
    info(DimensionDisplayValue);
}
</pre>




<p>Output for example:<br />
5170-10-00AB03---1500-<br />
&nbsp;
</p>]]></description>
<category>Microsoft Dynamics AX (Axapta)</category>
<pubDate>Wed, 21 May 2014 21:40:00 +0200</pubDate>
<link>https://www.schweda.net/blog_ax.php?bid=514&amp;wdl=en</link>
<comments>https://www.schweda.net/blog_ax.php?bid=514&amp;wdl=en</comments>
<guid isPermaLink="true">https://www.schweda.net/blog_ax.php?bid=514&amp;wdl=en</guid>
<author>heinz.schweda@schweda.net (Heinz Schweda)</author>
<wfw:commentRss>https://www.schweda.net/blog_ax.php?bid=514&amp;wdl=en</wfw:commentRss>
</item>
<item>
<title><![CDATA[AX 2012: Show financial dimension using display method]]></title>
<description><![CDATA[
<p>Following display-method (created in the datasource of the form custtable)&nbsp;shows the&nbsp; financial dimension Costcenter.
</p>


<pre class="pre_blog_axcode">
public display DimensionValue showCostCenter(CustTable _custTable)
{
    DimensionAttributeValueSet dimensionAttributeValueSet;
    DimensionAttributeValueSetItem dimensionAttributeValueSetItem;
    DimensionAttributeValue dimensionAttributeValue;
    DimensionAttribute dimensionAttribute;

    #define.CostCenterDimensionName(&quot;CostCenter&quot;);
 
    if( !_custTable || !_custTable.DefaultDimension)
    {
        return &#39;&#39;;
    } 

    dimensionAttributeValueSet = DimensionAttributeValueSet::find(_custTable.DefaultDimension); 

    select firstOnly RecId
    from dimensionAttributeValueSetItem
        where dimensionAttributeValueSetItem.DimensionAttributeValueSet == dimensionAttributeValueSet.RecId
    join DimensionAttributeValue
        where DimensionAttributeValue.RecId == dimensionAttributeValueSetItem.DimensionAttributeValue
    join RecId from dimensionAttribute
    where dimensionAttribute.RecId == DimensionAttributeValue.DimensionAttribute
       &amp;&amp; dimensionAttribute.Name  == #CostCenterDimensionName
    

    if(dimensionAttributeValue &amp;&amp; dimensionAttribute)
    {
        return dimensionAttributeValue.getValue();
    }

    return &#39;&#39;;
}

</pre>


<p><strong>Simpler version (see comments)</strong>
</p>


<pre class="pre_blog_axcode">
public display DimensionValue showCostCenter(CustTable _custTable)
{
    #define.CostCenterDimensionName(&quot;CostCenter&quot;);
 
    return ((select firstOnly DisplayValue from DefaultDimensionView
             where DefaultDimensionView.Name == #CostCenterDimensionName
                &amp;&amp; DefaultDimensionView.DefaultDimension == _custTable.DefaultDimension).DisplayValue);
}

</pre>]]></description>
<category>Microsoft Dynamics AX (Axapta)</category>
<pubDate>Thu, 13 Feb 2014 21:40:00 +0100</pubDate>
<link>https://www.schweda.net/blog_ax.php?bid=501&amp;wdl=en</link>
<comments>https://www.schweda.net/blog_ax.php?bid=501&amp;wdl=en</comments>
<guid isPermaLink="true">https://www.schweda.net/blog_ax.php?bid=501&amp;wdl=en</guid>
<author>heinz.schweda@schweda.net (Heinz Schweda)</author>
<wfw:commentRss>https://www.schweda.net/blog_ax.php?bid=501&amp;wdl=en</wfw:commentRss>
</item>
<item>
<title><![CDATA[AX 2012: Enter financial dimension based on an form input]]></title>
<description><![CDATA[
<p>Sometimes you have the requirement that a certain financial dimension is to be&nbsp;set on the basis of an input in a form.
</p>


<p>The following code example is something relatively easy to implement. In the example, whenever a particular field is changed - queried on the method <em>modified() </em>of the field of a DataSource, the financial dimension <em>Costcenter </em>will be filled with the value <em>25</em>. If the value to be entered an invalid, nothing happens (error message or similar).
</p>


<pre class="pre_blog_axcode">
public void modified()
{
    DimensionAttribute DimensionAttribute = DimensionAttribute::findByName(&quot;Costcenter&quot;);
    DimensionValue newValue = &#39;25&#39;;    // New dimension value
    
    super();
    
    dimensionDefaultingController.setDimensionAttributeValue(
&nbsp;       DimensionAttribute,
        DimensionAttributeValue::findByDimensionAttributeAndValue(DimensionAttribute, newValue).RecId, 
        newValue);
}
</pre>


<p>In the example, an existing instance of DimensionDefaultingController used.<br />
&nbsp;
</p>]]></description>
<category>Microsoft Dynamics AX (Axapta)</category>
<pubDate>Sat, 08 Feb 2014 18:09:00 +0100</pubDate>
<link>https://www.schweda.net/blog_ax.php?bid=497&amp;wdl=en</link>
<comments>https://www.schweda.net/blog_ax.php?bid=497&amp;wdl=en</comments>
<guid isPermaLink="true">https://www.schweda.net/blog_ax.php?bid=497&amp;wdl=en</guid>
<author>heinz.schweda@schweda.net (Heinz Schweda)</author>
<wfw:commentRss>https://www.schweda.net/blog_ax.php?bid=497&amp;wdl=en</wfw:commentRss>
</item>
<item>
<title><![CDATA[AX 2012: Selecting the values of a financial dimension]]></title>
<description><![CDATA[
<p>The following job demonstrates how to display the values of a financial dimension - in the example <em>Department </em>- via X++.
</p>


<pre class="pre_blog_axcode">
static void getValues4Dimension(Args _args)
{
    DimensionValueService dimensionValueService;
    DimensionContract dimensionContract;
    List dimensionValueContractList;
    ListEnumerator listEnumerator ;
    DimensionValueContract dimensionValueContract;
    DimensionValue dimensionValue;

    dimensionValueService = new DimensionValueService();
    dimensionContract = new DimensionContract();
    dimensionContract.parmDimensionName(&#39;Department&#39;);
    dimensionValueContractList = dimensionValueService.getDimensionValues(dimensionContract);
    listEnumerator = dimensionValueContractList.getEnumerator();

    setPrefix(strFmt(&quot;Dimension %1: &quot;, dimensionContract.parmDimensionName()));
    while(listEnumerator.moveNext())
    {
        dimensionValueContract = listEnumerator.current();
        dimensionValue = dimensionValueContract.parmValue();

        info(dimensionValue);
    }
}
</pre>]]></description>
<category>Microsoft Dynamics AX (Axapta)</category>
<pubDate>Sun, 13 May 2012 20:45:00 +0200</pubDate>
<link>https://www.schweda.net/blog_ax.php?bid=431&amp;wdl=en</link>
<comments>https://www.schweda.net/blog_ax.php?bid=431&amp;wdl=en</comments>
<guid isPermaLink="true">https://www.schweda.net/blog_ax.php?bid=431&amp;wdl=en</guid>
<author>heinz.schweda@schweda.net (Heinz Schweda)</author>
<wfw:commentRss>https://www.schweda.net/blog_ax.php?bid=431&amp;wdl=en</wfw:commentRss>
</item>
</channel>
</rss>	
