Options

Printing Credit Memo Problem

MauddibMauddib Member Posts: 269
3.70.B

In sales and receivables there is an option of "Posted Invoices" and in here there is a PRINT button. This print button printed the invoice you were on.

I have added menu items inside this button so we can now print out the invoice in one of two formats. An EU format and a US format.

However since I made this change something odd has happened. When you go to sales and receivables and into "Credit Memos". You set up a Credit Memo here and hit the "Post and Print" option.

When the user does this now, it prints out Every credit memo on the system! Not just the one you set up.

I am not sure even where to START looking for the problem and would appreciate suggestions. If you need to see any code from any tables or codeunits then please mail me and ask for them gavin.mcbride@gmail.com

GaMBe

Comments

  • Options
    krikikriki Member, Moderator Posts: 9,090
    Have you already tried the debugger?
    Check Codeunit 82 from where the printing starts and see what Navision does.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    KowaKowa Member Posts: 918
    You should have a codeblock like this one in the GetReport function in CU 82.
    This sets the filter on the Credit memo to print after the Credit Memo has been posted. If that does not work then probably the
    "Last Posting No." in the sales header is not filled correctly.


    "Document Type"::"Credit Memo":
    BEGIN
    IF "Last Posting No." = '' THEN
    SalesCrMemoHeader."No." := "No."
    ELSE
    SalesCrMemoHeader."No." := "Last Posting No.";
    SalesCrMemoHeader.SETRECFILTER;
    PrintReport(ReportSelection.Usage::"S.Cr.Memo");
    END;
    Kai Kowalewski
  • Options
    MauddibMauddib Member Posts: 269
    Thanks, the line in code unit 82 had changed from...

    S.cr.memo

    to......

    S.invoice

    Has anyone experienced this? All I did was...

    1) Edit the form you get when you go into "posted credit memos"
    2) Added a new report for the new invoice
    3) Edited the sales credit memo header table slightly
    4) added the option s.invoice2 to the report selections table.

    So why would codeunit 82 change itself???

    GaMBe
  • Options
    DenSterDenSter Member Posts: 8,304
    When you insert an option in the middle of the option string, the integers represented by the options don't change, they just shift over one step.

    So let's say you start with this option string:
    one,two,three

    Internally, Navision stores that as 1,2,3. In the code editor a value of 2 will show up as MyField::two, but when you close it, internally it reverts back to the value 2.

    Now, when you change the option string, by inserting an option in the middle, like so:
    one,oneB,two,three

    Internally, Navision stores this as 1,2,3,4. The tricky part however, is that when you now open your codeunit with the value 2, it will now display MyField::oneB, which is what the value 2 now means, when in fact you intended it to say MyField::two.

    So, when you need to add an option, add it to the end of the option string, and even give yourself some room if you need to add one to a standard Navision field, so you don't get into upgrade trouble when Navision adds an option themselves.

    Let's say you want to add a document type to the sales order. Instead of inserting the new one in between one of the existing ones:
    ,G/L Account,Item,NewType,Resource,Fixed Asset,Charge (Item)

    you do this:
    ,G/L Account,Item,Resource,Fixed Asset,Charge (Item),,,,,,,,,,,,,NewType

    The first one will completely screw up your sales posting, because all option values after the Item value will shift one over. By adding it at the end, Navision assigns it the higher, additional, value and you can just add the code to the system. By the way, as long as you don't put any spaces between the empty option values, the NewType should just appear at the end of the list.
Sign In or Register to comment.