GET data from Table to another

hi everyone,
as i am still not very familiar with Nav, i have a small task but i dont know how to write my Code to get into the solution.

i got an INVoice number , example INV254524 and i need to findo out the order number based on the Values stored in the primary Key.
table 36 have got 2 Primary keys / type Option which makes it complex for me.

any Idea how can i write the code please?

thank you in advance,

Ayoub

Answers

  • kylehardinkylehardin Member Posts: 257
    The primary key for Sales Header (Table 36) is Document Type,No.

    So you can get to your specific order two different ways. The first is a simple GET, which doesn't set any sort of filters, but just fetches a specific record. The second way sets two filters on the primary key fields and then does a find to fetch the matching record(s).

    The distinction between the two ways is the number of records returned. GET will always, only, get you a single record. FIND can return multiple records.

    1:
    SalesHeader.GET(SalesHeader."Document Type"::Order, 'INV254524');

    2"
    SalesHeader.SETRANGE("Document Type", SalesHeader."Document Type"::Order);
    SalesHeader.SETRANGE("No.", 'INV254524');
    SalesHeader.FINDSET;
    Kyle Hardin - ArcherPoint
  • afarrafarr Member Posts: 287
    Ayoub,

    We have all been beginners at some point, but ideally the company should give time for training and/or assign a mentor.

    Regarding your query, when you say invoice, do you mean posted invoice, or unposted invoice?

    If you start with an unposted invoice, and post it, you get a posted invoice; there is no order involved.
    But if you start with an (unposted) order, when you post it you get a posted invoice and/or a posted shipment.

    Alastair
    Alastair Farrugia
  • RockWithNAVRockWithNAV Member Posts: 1,139
    What kylehardin suggested will work but instead of -
    SalesHeader."Document Type"::Order , I believe it should be
    SalesHeader."Document Type"::Invoice, because you have Invoice number.
Sign In or Register to comment.