Sales Invoice

Lorneagle
Lorneagle Member Posts: 6
Hi everybody

I'm new to Navision and i have a problem accessing a Sales Invoice.
I created a button in Form 43 Sales Invoice:
Send - OnPush()

SalesInvoiceHeader.INIT;
SalesInvoiceHeader."No." := "No.";
SalesInvoiceHeader.FIND('=');

SalesInvoiceHeader is a global variable of type Record and Subtype Sales Invoice Header

But if i open an invoice and push the button, Navision tells me that there is no "Sales Invoice Header.No" equal to the No. of the invoice i just opened.
Isn' t the "Sales Invoice Header" record the right place to reference an existing invoice?

And how can i access the Data in the Sales Invoice Line of an Sales Invoice.

I am so confused :)

Thanks in advance for answers

Comments

  • David_Singleton
    David_Singleton Member Posts: 5,479
    Firstly, what are you actually trying to do. Although you are using the wrong records, even if done right, this really is the wrong way to do what ever it is you are trying to do.

    The technical issue, is that there is a difference between a Posted Sales Invoice and a Sales Invoice. A sales invoice is Table 36, a Posted Sales invoice is table 112.
    David Singleton
  • Waldo
    Waldo Member Posts: 3,412
    Indeed,

    first tell us what you are trying to do...

    Second,
    You could replace your code with:
    SalesInvoiceHeader.GET("No.");
    
    And then do your thing that you want to do... .

    To access the data of Sales Invoice Line, here is some code:
    SalesInvoiceLine.SETRANGE("Document No.", "No.");
    IF SalesInvoiceLine.FIND('-') THEN
      REPAT
        <Do your thing>
      UNTIL SalesInvoiceLine.NEXT = 0;
    

    But again,
    try to explain on what you are trying to do, then we can tell you what might be the best way to do it ...

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • Lorneagle
    Lorneagle Member Posts: 6
    First of all thx for the input how to access the subform :)

    What i want ( or try) to do:
    I want to export an invoice to an XML-File and send a message to a MSMQ.

    So i planed to pass the invoice record to a codeunit which sends the MSMQ message and calls XMLPort (or something similar) to export the record.

    But i already fail trying to pass the invoice record that i am working on to another codeunit ^^