Skip to main content

Notifications

Dynamics 365 Community / Forums / Finance forum / Finding the relevant S...
Finance forum
Unanswered

Finding the relevant Sales/Quotation/Confirmation/Invoice line from a SalesPurchLine

Posted on by 149
I have an extension to the calcPrice2LineAmount method of the SalesPurchLine class.
 
I wish to find the relevant transactionLine which is being processed via the salespurchline map in my extension.
I however do not know how to. The mappings seem to be gone, having been replaced by parm methods, but some (this one may seem relevant)
are not even implemented:
 
public SourceDocumentLineRecId parmSourceDocumentLine()
{
    throw error(Error::missingOverride(funcName()));
}
 
Approaching such a property directly does not work either, resulting in the error that a field with id 0 does not exist on the table
(despite it being there, as it can be seen in the debugger):
SalesPurchLine salesPurchLine = this.parmSalesPurchLine();

int64 testRecId  = salesPurchLine.SourceDocumentLine;
 
Does someone know how I can correctly find the relevant salesConfirmationLine, salesQuotationLine, Salesline or SalesInvoiceLine which is being processed here?
  • Superbunny Profile Picture
    Superbunny 149 on at
    Finding the relevant Sales/Quotation/Confirmation/Invoice line from a SalesPurchLine
    Hey Martin,
     
    THank you for your reply.
     
    Allow me to explain what I wish to do in order to more clearly show my problem:
     
    FUNCTIONAL:
    -I want to add a percentual charge field to my SalesQuotationLine, SalesLine, SalesConfimationLine and SalesInvoiceLine.
    -This field is uses between some of the standard fields in the calculation for lineAmount
     
    TECHNICAL:
    -I figured I had to extend PriceDisc.price2Amount, so I did that
    -I this context I had no acces to my custom field, so I checked the callstack and found as caller:
    SalesPurchLineInterface.calcPrice2LineAmount, so I extended this one. In the method I save a reference to my custom field, so afterwards, in the pricedisc method, this value can be taken out and used for the calculation.
     
    So I chose the interface extension, since I saw it in the callstack. Afterwards I found the following link, which allowed me to extend the SalesLineSalesPurchLine:
    https://learn.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/extensibility/maps-as-interfaces

    It seems now (previously I used only the initFromSalesLine, initFromQuotationLine, etc, which do not add the value for lineAmount) that my lineAmounts are being correctly calculated with this solution.
     
    Im not sure if I created a correct and valid implementation like this or if this functionality could be created in a much simpler way
  • Martin Dráb Profile Picture
    Martin Dráb 229,067 Most Valuable Professional on at
    Finding the relevant Sales/Quotation/Confirmation/Invoice line from a SalesPurchLine
    parmSourceDocumentLine() isn't implemented in the parent abstract class (SalesPurchLineInterface), because it can't be written in a generic way. The implementation must be done in child classes, e.g. SalesLineSalesPurchLine.

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

News and Announcements

Forum Structure Changes Coming Soon!

Quick Links

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,782 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,067 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,150

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans