Skip to main content

Notifications

Announcements

No record found.

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

  • alinawaz Profile Picture
    193 on at
    RE: Get Financial Dimension value (Department) using X++ code in PurchPurchaseOrder DP For PO Report

     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

  • Suggested answer
    Ramesh lella Profile Picture
    30 on at
    RE: Get Financial Dimension value (Department) using X++ code in PurchPurchaseOrder DP For PO Report

    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

  • Suggested answer
    JII SAADUDDIN Profile Picture
    1,832 on at
    RE: Get Financial Dimension value (Department) using X++ code in PurchPurchaseOrder DP For PO Report

    Thats fine! Ab,

    Verified answered is very much thankful than to say welcome!

  • Community Member Profile Picture
    on at
    RE: Get Financial Dimension value (Department) using X++ code in PurchPurchaseOrder DP For PO Report

    Thank you soo Much 

    Saaduddin its Working :) 

  • Suggested answer
    JII SAADUDDIN Profile Picture
    1,832 on at
    RE: Get Financial Dimension value (Department) using X++ code in PurchPurchaseOrder DP For PO Report

    Hi, Ab! Try this

    //where dimAttrValueSetItem.DimensionAttributeValueSet == dimAttrValueSet.RecId

    where dimAttrValueSetItem.DimensionAttributeValueSet >= dimAttrValueSet.RecId

  • Suggested answer
    Mahmoud Hakim Profile Picture
    17,887 on at
    RE: Get Financial Dimension value (Department) using X++ code in PurchPurchaseOrder DP For PO Report

    You can check this blog

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

  • Suggested answer
    Sukrut Parab Profile Picture
    71,687 Moderator on at
    RE: Get Financial Dimension value (Department) using X++ code in PurchPurchaseOrder DP For PO Report

    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

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics AX (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 100 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 48

#3
shanawaz davood basha Profile Picture

shanawaz davood basha 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans