How to put code in between for AL extension?

julkifli33julkifli33 Posts: 826Member
edited 2018-10-09 in NAV Three Tier
Hi All.
I am planning to migrate all my code from C/AL to AL
some can use events
but how about if i want to put my code in between nav standard code

for example
In table 37 (Sales Line), there is function name CalcVATAmountLines
in the middle of the function there is code like this
//Nav Standard
 CASE QtyType OF
          QtyType::General:
            BEGIN
              VATAmountLine.Quantity += "Quantity (Base)";
              VATAmountLine.SumLine(
                "Line Amount","Inv. Discount Amount","VAT Difference","Allow Invoice Disc.","Prepayment Line");
            END;

I want to change to my customized code like this
I have added 3 more parameters for sumline function
//CAL Customization
CASE QtyType OF
          QtyType::General:
            BEGIN
              VATAmountLine.Quantity += "Quantity (Base)";
              VATAmountLine.SumLine(
                "Line Amount","Inv. Discount Amount","VAT Difference","Allow Invoice Disc.","Prepayment Line",2,"Document Type","Document No.");
            END;

and in the table 290 (VAT Amount Line)

[External] SumLine

"Line Amount" += LineAmount;
IF AllowInvDisc THEN
"Inv. Disc. Base Amount" += LineAmount;
"Invoice Discount Amount" += InvDiscAmount;
"VAT Difference" += VATDifference;
IF Prepayment THEN
"Includes Prepayment" := TRUE;
//Start Customized
"Transaction Type" := ParTransactionType;
"Document Type" := ParDocumentType;
"Document No." := ParDocumentNo;
//End Customized
MODIFY;

all the bold one is my customized code
how should i do that in AL?
Thanks before

Answers

  • Slawek_GuzekSlawek_Guzek Posts: 1,619Member
    You can't :) That's the "beauty" of AL / extensions - you cannot modify existing code.
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • EkinEkin Posts: 22Member
    edited 2018-10-09
    You can create custom codeunits and find out what subscribers you can use for these tables and create your custom code there.
  • julkifli33julkifli33 Posts: 826Member
    I can add event for before or after
    But how about in between standard code?
  • SuDSuD Posts: 95Member
    You can't do any change in standard code :neutral: .
  • BlackTigerBlackTiger Posts: 1,178Member
    edited 2018-10-09
    Welcome to the Microsoft's vision of future NAV "development". Good luck.
    Guys in Microsoft live on another globe or may be in parallel Universe.
    "You can’t just ask customers what they want and then try to give that to them.
    By the time you get it built, they’ll want something new.” Steve Jobs
Sign In or Register to comment.