Hi folks,
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?
Answers
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.
That's the small dot which delimits the number and the customer name.
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.
Went through by debugger. It is most certainly within the call of SalesHeaderG.GET.
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.
Sorry, somehow missed that you already have SalesHeaderG.RESET line in your code
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
xStepa
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
If you wrote your code "OnInsert" trigger - it can be the answer.