Modify function in Existing Standard Codeunit 81 "Sales-Post (Yes/No)" in AL.

GhizlaneGhizlane Member Posts: 45
edited 2019-04-08 in NAV Three Tier
Hi All!
Can you please advice how to change/remove code from default codeunit .
let say for my example if i want to remove invoice and ship from codeunit 81 "Sales-Post (Yes/No)" !
Can you please advice how to achieve this from AL ? (Business central)

csoli73nc20q.png

Best Answers

  • GhizlaneGhizlane Member Posts: 45
    Answer ✓
    I change the variables as parameters and it does work :D:)
    tybcvfzzzota.png

    urz8dow3pgp2.png

    But I don't understand why it does work even if the functions doesn't have the same name as codeunit 81(standard) (ConfirmPost;MyConfirmPost)

Answers

  • SanderDkSanderDk Member Posts: 502
    Is you run the eventrecord page and start recording you can see which event you can hook into..
    Or read the code in C/Side
    For help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.
  • DuikmeesterDuikmeester Member Posts: 308
    Create a subscriber on Codeunit 81 OnBeforeConfirmSalesPost which has the parameters:
    VAR SalesHeader : Record "Sales Header" <= Set SalesHeader.Ship := TRUE and SalesHeader.Invoice := TRUE;
    VAR HideDialog : Boolean <= Set HideDialog := TRUE;
    VAR IsHandled : Boolean <= Set IsHandled := TRUE;
  • GhizlaneGhizlane Member Posts: 45
    Hi Dukmeester
    Even if I add this parametres I still have the same dialog

    0kn67xf61tn5.png

    yuh9cb2a9j9v.png

  • GhizlaneGhizlane Member Posts: 45
    Hi SanderDk,
    I know that I should modify OnBeforeConfirmSalesPost event on Codeunit 81, but I don't know how I can do it .
    can you please advice me?
  • TallyHoTallyHo Member Posts: 417
    edited 2019-04-09
    You should add SalesHeader, HideDialog, and so on (check OnBeforeConfirmSalesPost parameters in CU81) as parameters of your Eventsubscriber. And even then, you will only be able to skip the posting, skip the dialog, or fill the default option of the dialog. There will be three options on it if it is shown, I don't see how to change that using AL code. That being said.. set IsHandled to true, and write your own "CU81" that's probably the way to go now.
  • GhizlaneGhizlane Member Posts: 45
    as you know in business central i can't modify on standard code and there isn't a way to create an extension of codeunit
    the solution is created eventsubscriber .
    I try to create it but I don't know how can I acces to function on standard codeunit and modify it .
    I wanna to remove option ship and invoice
    if you have any idea would you help me .
    thnx
  • DuikmeesterDuikmeester Member Posts: 308
    edited 2019-04-09
    You defined the SalesHeader, HideDialog, IsHandled variables as locals instead of parameters.

    os0wrmrf5ela.png

    All as VAR ofcourse.
  • GhizlaneGhizlane Member Posts: 45
    I try it but I get the same dialog box .
  • DuikmeesterDuikmeester Member Posts: 308
    :s if you used VAR SalesHeader;VAR HideDialog;VAR IsHandled then I have no clue why it would not work. Can only think the extension was not properly activated or something. Run with debug and put a breakpoint on the first line in the extension.
  • TallyHoTallyHo Member Posts: 417
    edited 2019-04-09
    If you run it with IsHandled := true, nothing wil happen, CU81 is exited.
    If you run it with HideDialog := true, no dialog wil appear.
    You cannot change the appearance of dialog with this.
    So, set Ishandled to true, and write own code. This is the only way to change appearance.
  • MesutGMesutG Member Posts: 19
    Please try the my code

    70xv38ixy26c.png
  • GhizlaneGhizlane Member Posts: 45
    edited 2019-04-10
    Hi MesutG,
    I try the code that you write me,
    o7w0uk4f56ok.png

    zqre0izeby6d.png

    1l8j98py2cjc.png

    this is result ,
    it showed two dialog box.
    it's possible hide the dialog box that contain (ship invoice ship and invoice)??

    best regards


  • krikikriki Member, Moderator Posts: 9,115
    [Topic moved from 'NAV Courses, Exams & Certification' forum to 'NAV Three Tier' forum]

    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • GhizlaneGhizlane Member Posts: 45
    Answer ✓
    I change the variables as parameters and it does work :D:)
    tybcvfzzzota.png

    urz8dow3pgp2.png

    But I don't understand why it does work even if the functions doesn't have the same name as codeunit 81(standard) (ConfirmPost;MyConfirmPost)

Sign In or Register to comment.