Skip to main content

Notifications

Announcements

No record found.

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

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

(1) ShareShare
ReportReport
Posted on by 191
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 191 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 230,994 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

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…

Vahid Ghafarpour – Community Spotlight

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

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,994 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans