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, ...
Unanswered

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

(1) ShareShare
ReportReport
Posted on by 329
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?
I have the same question (0)
  • Superbunny Profile Picture
    329 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
    236,258 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,257

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 611 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans