Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

How to get Financial Dimension Cost Center value for the Report!

(0) ShareShare
ReportReport
Posted on by 1,869

Dear all,

I need financial dimension cost center value for Purchase order confirmation report. I wrote following method on purchtable to get the value cost center for all purchase order reports. Please kindly have a look on below method and its not returning any value. 

public str getCostCenterByDefaultDimension()
{
DimensionAttributeValueSetStorage dimStorage;
Str costCenter;
Counter i;

dimStorage = DimensionAttributeValueSetStorage::find(this.DefaultDimension);

for (i= 1 ; i<= dimStorage.elements() ; i++)
{
 
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == 'CostCenter')
{
costCenter = dimStorage.getDisplayValueByIndex(i);
}
}

return costCenter;
}

Best Regards,

Faqru Shaik

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to get Financial Dimension Cost Center value for the Report!

    Hi Faqru

    You can try restarting the service SQL Server Reporting Services,

    I happened something similar

    Regards

    Adrian M.

  • XB Profile Picture
    XB 1,867 on at
    RE: How to get Financial Dimension Cost Center value for the Report!

    That I show was an example you have to modify to your requirements.

    If you want a display on vendTable do something like:

    display DimensionValue displayCostCenterDimension()

    {

    DimensionAttributeValueSetStorage dimensionAttributeValueSetStorage ;

    DimensionAttribute dimensionAttribute;

    DimensionValue dimensionValue;

    #define.DimensionName("CostCenter")

    dimensionAttributeValueSetStorage = dimensionAttributeValueSetStorage::find(this.DefaultDimension);

    dimensionAttribute = dimensionAttribute::findbyname(#DimensionName);

    dimensionValue = dimensionAttributeValueSetStorage.getDisplayValueByDimensionAttribute(dimensionAttribute.recId);

    return dimensionValue;

    }

    Of course this method have to be on VendTable.

  • Faqruddin Profile Picture
    Faqruddin 1,869 on at
    RE: How to get Financial Dimension Cost Center value for the Report!

    As a Job

    O/P:

    job2.jpg

    For vendor Form

    Code in VednTable..

    display DimensionValue displayCostCenterDimension()
    {
    DimensionAttributeValueSetStorage dimensionAttributeValueSetStorage ;
    DimensionAttribute dimensionAttribute;
    VendTable vendTable;
    DimensionValue dimensionValue;
    #define.DimensionName("CostCenter")
    while select vendTable
    {
    dimensionAttributeValueSetStorage = dimensionAttributeValueSetStorage::find(vendTable.DefaultDimension);
    dimensionAttribute = dimensionAttribute::findbyname(#DimensionName);
    dimensionValue = dimensionAttributeValueSetStorage.getDisplayValueByDimensionAttribute(dimensionAttribute.recId);

    }
    return dimensionValue;
    }

    O/P: 

    job2.jpg

    Every vendor holds different cost center. But its giving only single cost center to all vendors. 

  • Verified answer
    XB Profile Picture
    XB 1,867 on at
    RE: How to get Financial Dimension Cost Center value for the Report!

    try this on a job

    static void displayCostCenterDimension()

    {

    DimensionAttributeValueSetStorage dimensionAttributeValueSetStorage ;

    DimensionAttribute dimensionAttribute;

    VendTable vendTable;

    DimensionValue dimensionValue;

    #define.DimensionName("CostCenter")

    while select vendTable

    {

    dimensionAttributeValueSetStorage = dimensionAttributeValueSetStorage::find(vendTable.DefaultDimension);

    dimensionAttribute = dimensionAttribute::findbyname(#DimensionName);

    dimensionValue = dimensionAttributeValueSetStorage.getDisplayValueByDimensionAttribute(dimensionAttribute.recId);

    info(dimensionValue);

    }

    }

  • XB Profile Picture
    XB 1,867 on at
    RE: How to get Financial Dimension Cost Center value for the Report!

    of course you are doing a select firstonly you need to do a while select statement to check if code run ok and show all records

  • Faqruddin Profile Picture
    Faqruddin 1,869 on at
    RE: How to get Financial Dimension Cost Center value for the Report!

    Hi Javier,

    I try that job for vendor form but its returning same Costcenter for all vendors. Check this..

    display DimensionValue displayCostCenterDimension()
    {
    DimensionAttributeValueSetStorage dimensionAttributeValueSetStorage ;
    DimensionAttribute dimensionAttribute;
    VendTable vendTable;
    DimensionValue dimensionValue;
    //Nombre de la dimensión que buscaremos
    #define.DimensionName("CostCenter")
    select firstOnly vendTable;

    dimensionAttributeValueSetStorage = dimensionAttributeValueSetStorage::find(vendTable.DefaultDimension);
    dimensionAttribute = dimensionAttribute::findbyname(#DimensionName);
    dimensionValue = dimensionAttributeValueSetStorage.getDisplayValueByDimensionAttribute(dimensionAttribute.recId);

    return dimensionValue;
     
    }

    O/P:

    vend.jpg

  • XB Profile Picture
    XB 1,867 on at
    RE: How to get Financial Dimension Cost Center value for the Report!

    And what is the name of your dim?

    With this code you have be able to read dim value.

    axlearn.blogspot.com.es/.../3_26.html

  • Faqruddin Profile Picture
    Faqruddin 1,869 on at
    RE: How to get Financial Dimension Cost Center value for the Report!

    NO..

    public DimensionValue displayCostCenter()

    {

    DefaultDimensionView defaultDimensionView;

    PurchTable purchTable;

    select firstOnly DisplayValue from defaultDimensionView

       where defaultDimensionView.DefaultDimension == purchTable.DefaultDimension

          && defaultDimensionView.Name             == "CostCenter";

       return defaultDimensionView.DisplayValue;

    }

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: How to get Financial Dimension Cost Center value for the Report!

    Let's try another way:

    DefaultDimensionView defaultDimensionView;
    
    select firstOnly DisplayValue from defaultDimensionView
        where defaultDimensionView.DefaultDimension == purchTable.DefaultDimension
           && defaultDimensionView.Name             == "CostCenter";
    


    Does this one return something ?

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: How to get Financial Dimension Cost Center value for the Report!

    I can see a record on your screenshot.

    However, you are saying that DimensionAttribute::findByName("CostCenter") does not return a record. This method does not do anything special, just

    select firstonly
               dimensionAttribute
           where
               dimensionAttribute.Name == _name

    So either it returns a record or something is completely wrong here ...

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,532 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,575 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans