SalesHeader not found even though it is existing and filters are set correctly

robthemobb
Member Posts: 14
Hi folks,
I have a piece of code as follows:
SalesHeaderG is a table 36 record, defined as global. The other both variables are text. If I run this code, I got following error, which is odd, because the sales header is existing obviously.

However, if I change the variable SalesHeaderG to local, it works. Please, can anybody tell me why?
I have a piece of code as follows:
CLEAR(SalesHeaderG); SalesHeaderG.RESET; IF IsReturnOrder = '1' THEN SalesHeaderG.GET(SalesHeaderG."Document Type"::"Return Order", SalesOrderNumber) ELSE SalesHeaderG.GET(SalesHeaderG."Document Type"::Order, SalesOrderNumber);
SalesHeaderG is a table 36 record, defined as global. The other both variables are text. If I run this code, I got following error, which is odd, because the sales header is existing obviously.

However, if I change the variable SalesHeaderG to local, it works. Please, can anybody tell me why?
0
Answers
-
can you double check value of SalesOrderNumber variable By putting a filter on sales header table, I can see a small ‘.’ at the end of salesHeader.”No.”.0
-
Is the global one temporary?Cheers
Carsten
==> How To Ask Questions The Smart Way
This post is my own opinion and does not necessarily reflect the opinion or view of my employer.1 -
rishi_rishabh123 wrote: »can you double check value of SalesOrderNumber variable By putting a filter on sales header table, I can see a small ‘.’ at the end of salesHeader.”No.”.
That's the small dot which delimits the number and the customer name.Is the global one temporary?
No, the variable wasn't temporary. I did check. I also did some tests hard-code the sales order number into the variable. This works also. So the code didn't get access to the field from the port, when the var was global, but when it was local.
I had some code, which is executed before the snippet I posted. But never called SalesHeaderG before.0 -
Have you checked that the error is indeed triggered when executing SalesHeaderG.GET or may be by another command?0
-
-
Please Check SalesHeader Table Primary Key , Is It Default Or You Change It?0
-
NavSolution wrote: »Please Check SalesHeader Table Primary Key , Is It Default Or You Change It?
It's default. I can't see any reason why someone should change it (on purpose).0 -
robthemobb wrote: »NavSolution wrote: »Please Check SalesHeader Table Primary Key , Is It Default Or You Change It?
It's default. I can't see any reason why someone should change it (on purpose).
Then There is No Issue In Code Check Company and Debug it.0 -
<DELETED>
Sorry, somehow missed that you already have SalesHeaderG.RESET line in your codeSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
Try SETRANGE , SETFILTER0
-
Have you checked that there is not another SalesHeaderG variable declared? I'm not sure how this could create your error since you use RESET, but...
0 -
I look forward to the solution as a child on the ice creamRegards
xStepa0 -
Can you post here the complete text definiion of your page?Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
Are you sure that on the moment of your code, required sales header already exist in the database?
If you wrote your code "OnInsert" trigger - it can be the answer.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