Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

How to change a process value in the middle of a function ?

(0) ShareShare
ReportReport
Posted on by

Hi,

Just looking for some advice or input. When we know in a standard class it has function that in the middle of the process we want to modify it. Is that possible and how ? 

To be precise, the issue I found is in a class named : RevRecCustPostInvoiceDeferredNew, in their function named : createDeferredLinesForInvoice(), if by any chance the line is same, I will be directing to Line 1059 

it has this code :

 if (RevRecUtil::findDiscountAccountForSalesOrder(salesLineBuffer))
                            {
                                netDeferredLine.LineAmount = _custInvoiceTrans.SalesPrice * _custInvoiceTrans.Qty;
                            }
                            else
                            {
                                netDeferredLine.LineAmount = _custInvoiceTrans.LineAmount;
                            }

Problem I found is with the netDeferredLine.LineAmount, as in "why the system need to check it has main account for Discount" ? I cannot find a good reason of checking this but this checking makes LineAmount in CustInvoiceTrans being calculate by multiplying SalesPrice & Qty, not following what already stated in LineAmount.

Unless my investigation is wrong, but if I'm using Price Include Sales Tax, the LineAmount which already excluded tax will be wrong again since Sales Price in this field still included tax.

In SQL, the CustInvoiceTrans will be like this ->

pastedimage1673605539027v2.png

And the point to my question is, this is in the middle of the method processing and after these code, the Line Amount will be used for other calculation as well, still inside the same method/function. So if I want to lets say modify it, lets say to ignore the Discount main account checking, how am I going to do that ? 

Thanks,

  • VoltesDev Profile Picture
    VoltesDev on at
    RE: How to change a process value in the middle of a function ?

    Hi Girish,

    You mean writing the same process in my CoC, and modify the middle part ? I think this is very risky not to mentioned what you saying of tedious and time consuming.

    I'd like more on the "onInsertingEventHandler", Thanks for suggesting. Let me try first.

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: How to change a process value in the middle of a function ?

    Hi VoltesDev,

    After the completion of the process, they are inserting the records into "RevRecDeferredLine" table. So, you need to either write COC for the method createDeferredLinesForInvoice and you need to find a way to update the record in "RevRecDeferredLine". But keep in mind that they are using RecordInsertList to insert records into "RevRecDeferredLine" table. In that method they are using the for loop to loop the lines based on the "numberOfScheduledLines" buffer. So, you need to do same process in COC which will be tedious and time consuming.

    If it doesn't work, you can write onInsertingEventHandler for table "RevRecDeferredLine " to somehow find a way to set the desired values before inserting values into table.

    Thanks,

    Girish S.

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

Announcing Our 2025 Season 1 Super Users!

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

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,817 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans