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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Updating financial dimension of Purchase Order header

(0) ShareShare
ReportReport
Posted on by 916

Hi there ,

The default Dimensions for PO Header is picked from the Vendor Master- this is standard function available in AX 2012 R2.So i make some change : When I create a Purchase Order I can inherit default dimension values in header of ordrerer , for that i was changed the value of defaultdimension field by worker value of defaultdimension .

After that , when i check dimension financial in PO Header , they all changed , but i want just only inherit  costcenter of ordrerer 

So , in wich class i can update this?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    301,194 Super User 2025 Season 2 on at

    Hi AlexAxing,

    There is a class where dimensions can be merged. If the worker dimension is still empty, it can be filled from the orderer. The class name is DimensionMerge. You can find an example how to use this class on the SalesLine table , method mergeDimension().

  • ALAhmed Profile Picture
    916 on at

    The business logic is when i create new PO , i want to inherit only default dimension CostCenter values in header of ordrerer and keep others dimension of vender . Now what i have do is i  inherit all dimension financial, so dimension are changed. You think i can get the defaultdimension of vendor and keep costcenter of  ordrerer  by using the method mergeDimension() of PURCHTABLE? somthing like that : 

    purchTable.DefaultDimension = purchTable.mergeDimension(VendTable.DefaultDimension,
    _purchTable.DefaultDimension);

  • André Arnaud de Calavon Profile Picture
    301,194 Super User 2025 Season 2 on at

    Hi AlexAxing,

    I do think the default dimension of the orderer is setup on the worker employment details, right?

    In that case you need to get the dimension of the worker. Note that the mergeDimension is actually used within the method InitFromInventTable of the SalesLineType class. Based on the example provided in my previous reply.

    Can you otherwise explain the current process?

  • ALAhmed Profile Picture
    916 on at

    In Standard AX2012 , The default Dimensions for PO Header is picked from the Vendor Master.

    1 : I was changed the standard : i have picked the default Dimensions for PO Header from orderer  , so i create this function in PurchTable  for that :

    public void UpdateDefaultDimensionPO(PurchPlacer  _workerPurchPlacer)

    {

       HcmWorker       hcmWorker;

       RefRecId        DefaultDim;

       hcmWorker = HcmWorker::find(_workerPurchPlacer);

       DefaultDim = (select firstOnly DefaultDimension from HcmEmployment

               where hcmEmployment.Worker == HcmWorker.RecId).DefaultDimension;

       this.DefaultDimension = DefaultDim;

    }  

    and in validateWrite of PurchTable i add this line this.UpdateDefaultDimensionPO(this.WorkerPurchPlacer);

    => the result :  when i create new PO then PO header view ->financial dimension all default dimension are change by the new value of DefaultDimension fiels.

    2 : what i want is picked the default dimension of Vendor Master and change only CostCenter by costcenter of Orderer.

    please tell m if is't clear for you?

    Others information : In PurchTable we have this method mergeDimension() and in the class PurchLineType we have this method : initFromPurchTable that use method mergeDimension

  • Brandon Wiese Profile Picture
    17,788 on at

    What other financial dimensions have you setup on your Worker record?  Just Cost center, or others too?

  • ALAhmed Profile Picture
    916 on at

    Here Payroll/Common/Workers/Employees -> edit ->Employement ->Dimension Financial : i setup others dimension like : CostCenter ,Dim1 , Dim2 , Dim3

    So when i create new PO i get what i setup here. so me iwant get only costcenter

  • Brandon Wiese Profile Picture
    17,788 on at

    By the way, you should not change record data in validateWrite().  It's a much better practice to do it in the write() method before the super();

  • ALAhmed Profile Picture
    916 on at

    Thnaks! and you have an idea about my question

  • Verified answer
    Brandon Wiese Profile Picture
    17,788 on at

    This might work for what you want.  Note that this is proof of concept code provided for discussion and educational purposes only, and should be tested.

    The task as I understood it was to extract just the Cost center financial dimension from the worker's DefaultDimension.  To do that, I exploded them into a Map object, so the financial dimensions could be worked with as individual elements.  I then removed all of the elements except Cost center.  Finally, I created a new DefaultDimension of just Cost center, which in theory could be merged with one from PurchTable or another record.

        DimensionAttribute dimensionAttribute = DimensionAttribute::findByName('CostCenter');
        Map dimensionSpecifiers;
        Set set;
        SetEnumerator se;
        List dimensionSources;
        DimensionDefault defaultDimension;
        ;
        
        dimensionSpecifiers = DimensionDefaultingEngine::getDefaultDimensionSpecifiers(worker.DefaultDimension);
        
        // at this point we have a map with all dimension specifiers
        
        set = dimensionSpecifiers.keySet();  // extract set of DimensionAttribute RecId's
        se = set.getEnumerator();
        while (se.moveNext())  // loop through all specifiers
        {
            if (se.current() != dimensionAttribute.RecId)  // all except CostCenter
                dimensionSpecifiers.remove(se.current());  // should be removed
        }
        
        // at this point we have a map with only the CostCenter specifier
        
        dimensionSources = new List(Types::Class);
        dimensionSources.addEnd(dimensionSpecifiers);
        
        defaultDimension = DimensionDefaultingEngine::getDefaultDimension(dimensionSources, false);
        
        // at this point we have the DefaultDimension for only Cost center

  • Dick Wenning Profile Picture
    8,705 Moderator on at

    please show me the code

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans