How to create many invoices via c/al code?

sbillysbilly Member Posts: 231
Hi all,
I want to know if it's possible to create many invoices via c/al code?
Thanks

Comments

  • VjekoVjeko Member Posts: 55
    Yes, it is :)

    Can you be more specific?
    (Co-)author of "Implementing Microsoft Dynamics NAV 2009"
    http://vjeko.com/
  • sbillysbilly Member Posts: 231
    I want to create 200 Invoices, but it will takes me much time, so I prefer to create them via C/Al code.
    For example every Invoice will be created with a customer and some lines
  • VjekoVjeko Member Posts: 55
    FOR i := 1 TO 200 DO BEGIN
      SalesHeader.INIT;
      SalesHeader."Document Type" := SalesHeader."Document type"::Invoice;
      SalesHeader.INSERT(TRUE);
      FOR j := 1 TO 5 DO BEGIN
        SalesLine.INIT;
        SalesLine."Document Type" := SalesHeader."Document Type";
        SalesLine."Document No." := SalesHered."Document No.";
        SalesLine."Line No." := j * 10000;
        SalesLine.INSERT(TRUE);
      END;
    END;
    

    There.
    (Co-)author of "Implementing Microsoft Dynamics NAV 2009"
    http://vjeko.com/
  • sbillysbilly Member Posts: 231
    Thanks for the code but when I put it in code unit and after variable declaration I recieve this message:
    The sale Header already exists
    Identification fields and values
    Document type = 'Invoice', No.='200'
  • vijay_gvijay_g Member Posts: 884
    Check the sales invoice no. series should be placed in setup.
  • sbillysbilly Member Posts: 231
    I checked that any Invoice with the no. in the message exists in the table 36.
    I checked too that the sales invoice no. is placed in setup.
  • SogSog Member Posts: 1,023
    add salesheader."No." = ''
    this should enable the trigger of the No. Series.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • sbillysbilly Member Posts: 231
    Sog wrote:
    add salesheader."No." = ''
    this should enable the trigger of the No. Series.
    it does not work
  • SogSog Member Posts: 1,023
    sbilly wrote:
    Sog wrote:
    add salesheader."No." = ''
    this should enable the trigger of the No. Series.
    it does not work
    if
    FOR i := 1 TO 200 DO BEGIN
      SalesHeader.INIT;
      SalesHeader."Document Type" := SalesHeader."Document type"::Invoice;
      Salesheader."Document No." = '';
      SalesHeader.INSERT(TRUE);
      FOR j := 1 TO 5 DO BEGIN
        SalesLine.INIT;
        SalesLine."Document Type" := SalesHeader."Document Type";
        SalesLine."Document No." := SalesHered."Document No.";
        SalesLine."Line No." := j * 10000;
        SalesLine.INSERT(TRUE);
      END;
    END;
    
    Does not work, then the validation of the salesheader is not standard or some setup is missing.
    Either way, by only stating, it doesn't work, we can't help you any further.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • sbillysbilly Member Posts: 231
    yessss, it works
    Thank you very much =D>
Sign In or Register to comment.