GET data from Table to another

AMoussaoui
Member Posts: 1
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
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
0
Answers
-
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 - ArcherPoint0 -
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.
AlastairAlastair Farrugia0 -
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.Thanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions