Skip to main content

Notifications

Announcements

No record found.

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 926

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.

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

    Great!

    Please mark the correct answer(s) as verified.

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

    Yes It is working!

  • Gunjan Bhattachayya Profile Picture
    35,421 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
    926 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

  • Khurshid Wali Profile Picture
    926 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

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,421 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
    926 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?

  • Gunjan Bhattachayya Profile Picture
    35,421 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?

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,961 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,801 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans