Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

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

Posted on by 1,844

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

  • 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,844 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,844 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,844 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,274 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,274 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 ...

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,768 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,985 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans