Options

Gen. Journal Line "Line No."

AmaraaAmaraa Member Posts: 153
Hello,

I wanted to write to table 81 from other form. How can I assign the "Line No." same as the AutoSplitKey property in the form?

Any ideas appreciated,
Amaraa

Answers

  • Options
    kinekine Member Posts: 12,562
    Did you tried it in some way? There is only one way: assign the correct no. through code... but Your description of what you want to do is too generic to give you more info...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    SavatageSavatage Member Posts: 7,142
    You basically need to filter on the table you want to "write" to. See if a line no exisits using "find". If so then increment the line no to the next line no.

    I've written a little code to automatically write a new line to the end of a purchase order if paid by credit card. Just focus on the setrange , find & "line no;" := "line no." + 10000;
    IF Status = Status::Open
     THEN BEGIN
      "Vendor Invoice No." := "No."+'-PAID';
      MODIFY;
      CALCFIELDS("Amount Including Tax");
      InvSetup.GET;
      Purchline.RESET;
      Purchline.SETRANGE(Purchline."Document Type","Document Type");
      Purchline.SETRANGE(Purchline."Document No.","No.");
       IF Purchline.FIND('+')
        THEN BEGIN
         Purchline."Line No." := Purchline."Line No."+ 10000;
         Purchline.VALIDATE(Purchline."Qty. Rcd. Not Invoiced",0);
         Purchline.VALIDATE(Purchline."Quantity Received",0);
         Purchline.Type := Purchline.Type::"Account (G/L)";
         Purchline.VALIDATE(Purchline."No.",InvSetup."Inventory Account (G/L)");
         Purchline.VALIDATE(Purchline.Quantity,1);
         Purchline.VALIDATE(Purchline."Direct Unit Cost",("InvLine Amount" * -1));
         Purchline.INSERT;
        END;
    END
     ELSE BEGIN
      MESSAGE('Purchase Order %1 must be open!',"No.");
    END;
    

    Take it from there..Let us know if you don't understand.
  • Options
    AmaraaAmaraa Member Posts: 153
    Savatage wrote:
    You basically need to filter on the table you want to "write" to. See if a line no exisits using "find". If so then increment the line no to the next line no.

    I've written a little code to automatically write a new line to the end of a purchase order if paid by credit card. Just focus on the setrange , find & "line no;" := "line no." + 10000;
    IF Status = Status::Open
     THEN BEGIN
      "Vendor Invoice No." := "No."+'-PAID';
      MODIFY;
      CALCFIELDS("Amount Including Tax");
      InvSetup.GET;
      Purchline.RESET;
      Purchline.SETRANGE(Purchline."Document Type","Document Type");
      Purchline.SETRANGE(Purchline."Document No.","No.");
       IF Purchline.FIND('+')
        THEN BEGIN
         Purchline."Line No." := Purchline."Line No."+ 10000;
         Purchline.VALIDATE(Purchline."Qty. Rcd. Not Invoiced",0);
         Purchline.VALIDATE(Purchline."Quantity Received",0);
         Purchline.Type := Purchline.Type::"Account (G/L)";
         Purchline.VALIDATE(Purchline."No.",InvSetup."Inventory Account (G/L)");
         Purchline.VALIDATE(Purchline.Quantity,1);
         Purchline.VALIDATE(Purchline."Direct Unit Cost",("InvLine Amount" * -1));
         Purchline.INSERT;
        END;
    END
     ELSE BEGIN
      MESSAGE('Purchase Order %1 must be open!',"No.");
    END;
    

    Take it from there..Let us know if you don't understand.
    Thanks ;)
  • Options
    CraineGACraineGA Member Posts: 28
    I have also benefited from this post, many thanks.
Sign In or Register to comment.