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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to reset Accounting distribution through x++

(0) ShareShare
ReportReport
Posted on by 928

Hello everyone,

I want to reset my accounting distribution whenever I change the default dimension on custom EP form. kindly share if you got any idea.

I found the method ResetDistribution in EPdistributionController class but it required parameter (Common _context) which I did not understand how to generate and pass.

I have the same question (0)
  • Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: How to reset Accounting distribution through x++

    Hi Khurshid,

    Do you have an accounting distribution screen in EP as well which you are trying to re-populate by resetting?

    If not, can't you write the code in field modified at the table level?

  • Khurshid Wali Profile Picture
    928 on at
    RE: How to reset Accounting distribution through x++

    Thank you, Gunjan for Replying,

    I am doing it in the Expense Report custom page. when I change financial dimension e.g Employee 0001 to 0002. changes appear on Distribute amount form but when I change Employee 0001 to empty. distribute amount form is showing Employee 0001 until I reset the distribution through reset button.

    I want reset distribute amount on modified method of default dimension.

    I tried to explore EPDistributionController class but failed to construct it in my method.

    Is there any way to reset from TrvExpTrans table or dataset?

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: How to reset Accounting distribution through x++

    Hi Khurshid,

    I was thinking about resetting when you save the expense report line. You can try checking like this before super() call in update() method -

    if (this.DefaultDimension != this.orig().DefaultDimension)
    {
        //Reset accounting distribution
    }

  • Khurshid Wali Profile Picture
    928 on at
    RE: How to reset Accounting distribution through x++

    I want to know how to do it through x++, I don't want to just delete related Distributions from Accounting distribution and create a new one.

    I want to do it in a proper way like reset method in EPDistributionController class.

    Properly initialized related class and do reset

  • Khurshid Wali Profile Picture
    928 on at
    RE: How to reset Accounting distribution through x++

    Hello Gunjan,

    I wrote this code to Reset Accounting distribution in update method of TrvExpTrans

    if(this.DefaultDimension != this.orig().DefaultDimension)
        {
            select RecId from accountingDistribution
                where accountingDistribution.SourceDocumentHeader == TrvExpTable::find(this.ExpNumber).SourceDocumentHeader
               && accountingDistribution.SourceDocumentLine == this.SourceDocumentLine;
            
            if(accountingDistribution)
            {
                epDistributionController = EPDistributionController::newController(this,MonetaryAmount::ExtendedPrice);
                epDistributionController.resetDistribution(accountingDistribution.RecId);
            }
        }
    super();

    The purpose is to update distribution on updating the default dimension.

    Thank you, Gunjan! for support.

    Kindly check my code final time and let me know if I am missing something.

    regards,

    khurshid wali

  • Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: How to reset Accounting distribution through x++

    Hi Khurshid,

    Is this working for you? I have to check the EPDistributionController part.

  • Khurshid Wali Profile Picture
    928 on at
    RE: How to reset Accounting distribution through x++

    Yes It is working!

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: How to reset Accounting distribution through x++

    Great!

    Please mark the correct answer(s) as verified.

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 765 Super User 2025 Season 2

#2
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 743

#3
Sumit Singh Profile Picture

Sumit Singh 551

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans