web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Get Financial Dimension value (Department) using X++ code in PurchPurchaseOrder DP For PO Report

(0) ShareShare
ReportReport
Posted on by

Hi Guy's I want to Get ConstCenter(Dimension ) in PO Report  my code is 

private str 255 getDeprtmentDim( PurchId _purchid)
//private PurchId getDeprtmentDim( )

{
//PurchId _purchid;
PurchTable PurchTable;
PurchLine PurchLine;
DimensionAttributeValueSet dimAttrValueSet;
DimensionAttributeValueSetItem dimAttrValueSetItem;
DimensionAttributeValue dimAttrValue;
DimensionAttribute dimAttr;
Common dimensionValueEntity;
;

// Find our supplier
// PurchLine = PurchLine::find('PO-00078');
PurchTable= PurchTable::find(_purchid);

// Find the dimension value set that the vendor points to (for specifying the
// 'default' dimensions). This table is used as a sort of 'header' that the
// value set items (DimensionAttributeValueSetItem) records belong to.
//dimAttrValueSet = DimensionAttributeValueSet::find(PurchLine.DefaultDimension);
dimAttrValueSet = DimensionAttributeValueSet::find(PurchTable.DefaultDimension);

// Find all of the 'value set items' linked against the 'value set'
while select dimAttrValueSetItem
where dimAttrValueSetItem.DimensionAttributeValueSet == dimAttrValueSet.RecId
{
// Find the dimension 'value' (DimensionAttributeValue) that the set item points to.
dimAttrValue = DimensionAttributeValue::find(dimAttrValueSetItem.DimensionAttributeValue);

// Find the underlying attribute.
dimAttr = DimensionAttribute::find(dimAttrValue.DimensionAttribute);

// Use the helper class to obtain a reference to the underlying entity (can be anything)
dimensionValueEntity = DimensionDefaultingControllerBase::findBackingEntityInstance(
curext(),
dimAttr,
dimAttrValue.EntityInstance);

//info(dimAttr.Name + ' ' + dimAttrValue.getValue());
If(dimAttr.Name=='Department')
{
return dimAttrValue.getValue();
}

}

return '';
}

 

if this code is fine then how to insert in PurchPurchaseOrderHeader Table and i also add field in

PurchPurchaseOrderHeader table 

please help me 

Thanks 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Sukrut Parab Profile Picture
    71,735 Moderator on at

    If you are getting value of department  you need then just add field in Temp table used in data provider and assign that value to that field . Refer below link about how to do that.

    technet.microsoft.com/.../gg724119.aspx

  • Suggested answer
    Mahmoud Hakim Profile Picture
    17,887 on at

    You can check this blog

    yasirnedian.blogspot.ae/.../get-default-financial-dimension-values.html

  • Suggested answer
    JII SAADUDDIN Profile Picture
    1,832 on at

    Hi, Ab! Try this

    //where dimAttrValueSetItem.DimensionAttributeValueSet == dimAttrValueSet.RecId

    where dimAttrValueSetItem.DimensionAttributeValueSet >= dimAttrValueSet.RecId

  • Community Member Profile Picture
    on at

    Thank you soo Much 

    Saaduddin its Working :) 

  • Suggested answer
    JII SAADUDDIN Profile Picture
    1,832 on at

    Thats fine! Ab,

    Verified answered is very much thankful than to say welcome!

  • Suggested answer
    Ramesh lella Profile Picture
    30 on at

    you can try this logic in display method : To get financial dimension values based on personnel number in hcmworker.

    tried for department value in the same way will get all financial dimension value.

    HcmEmployment hcmEmployment;

    DimensionAttributeValueSetItem setItem;

    DimensionAttributeValueSet dimAttrValueSet;

    DimensionAttributeValue dimAttrValue;

    DimensionAttribute dimAttribute;

    select * from hcmEmployment

    where hcmEmployment.Worker == _this.RecId

    join dimAttrValueSet

    where dimAttrValueSet.RecId == hcmEmployment.DefaultDimension

    join DisplayValue from setItem

    where setItem.DimensionAttributeValueSet == dimAttrValueSet.RecId

    join dimAttrValue

    where setItem.DimensionAttributeValue == dimAttrValue.RecId

    join dimAttribute

    where dimAttribute.RecId == dimAttrValue.DimensionAttribute && dimAttribute.Name =="Department";

    {

    info(strFmt("Employee = %1 %2 = %3 ",

    HcmWorker::find(hcmEmployment.Worker).PersonnelNumber,

    dimAttribute.Name, setItem.DisplayValue));

    }

    Thanks & regards

    Ramesh Lella

  • alinawaz Profile Picture
    209 on at

     Ramesh lella I have the exact same code and I am fetching Location and LineOfBusiness dimension from it but is there any way I can get the description of these dimension instead of their value ??
    pastedimage1654854086867v1.png

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 16

#2
GiacomoRovai Profile Picture

GiacomoRovai 4

#3
Douglas Noel Profile Picture

Douglas Noel 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans