GET Error

cavalcanti_space
Member Posts: 49
Hi guys,
I have this code on a report. the TempInvSalesHeader record is set as temp.
Item Ledger Entry - OnAfterGetRecord()
IF NOT TempInvSalesHeader.GET("Invoice No.") THEN BEGIN
InvSalesHeader.GET("Invoice No.");
TempInvSalesHeader := InvSalesHeader;
TempInvSalesHeader.INSERT;
END;
When I run it I get this error:
Sales Invoice Header No. 'NFVR00002' does not exist.
Does anyone know How I can sort this out???????
Cheers
I have this code on a report. the TempInvSalesHeader record is set as temp.
Item Ledger Entry - OnAfterGetRecord()
IF NOT TempInvSalesHeader.GET("Invoice No.") THEN BEGIN
InvSalesHeader.GET("Invoice No.");
TempInvSalesHeader := InvSalesHeader;
TempInvSalesHeader.INSERT;
END;
When I run it I get this error:
Sales Invoice Header No. 'NFVR00002' does not exist.
Does anyone know How I can sort this out???????
Cheers
0
Answers
-
cavalcanti_space wrote:IF NOT TempInvSalesHeader.GET("Invoice No.") THEN BEGIN
InvSalesHeader.GET("Invoice No.");
Always use get with IF like in 1st line.0 -
mohana_cse06 wrote:cavalcanti_space wrote:IF NOT TempInvSalesHeader.GET("Invoice No.") THEN BEGIN
InvSalesHeader.GET("Invoice No.");
Always use get with IF like in 1st line.
this is not really a good rule...if you always use an "if...get" you will never receive an error...
I often take advantage of these standard errors because:
- no translations needed in a multilanguage environment
- ensure data consistency
- easy-to-debug error
In your specific case, I think the program should act like this: you first try to get the invoice from a temptable; if there's no invoice with that no., you get the invoice from the real table and fill the temptable...if there are no invoices in the real table with that number, you MUST receive an error!
(is 'NFVR00002' a credit memo?)
P.S.: do you know what GET function does?it's not possible you've never seen errors like yours0 -
cavalcanti_space wrote:Does anyone know How I can sort this out???????
for this, i have given that solution.
if u have anyother solution for this please let us know.
thanks in advance0 -
This is simple there is no TempInvSalesHeader and no InvSalesHeader, in short there is no posted Sales Invoice with the number 'NFVR00002' on the system, once an invoice is printed the posted Sales Invoice can be deleted, go to Posted Sales Invoices and search for NFVR00002
Is NFVR00002 part of the posted number range or was this a Journal Entry?
So as already said you need a double condition to avoid this errorIF (NOT TempInvSalesHeader.GET("Invoice No.")) AND (InvSalesHeader.GET("Invoice No.")) THEN BEGIN TempInvSalesHeader := InvSalesHeader; TempInvSalesHeader.INSERT; END;
There ya go!
DavidAnalyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com0 -
I think the real problem is: "how did you put 'NFVR00002' in your personalized (or english local) field invoice no."?
If the invoice does not exists, we have 2 possibilities:
- the program failed to assign a correct "invoice no."
- someone deleted the sales invoice header
For the second case, you can use david cox's solution, otherwise, you have to investigate how do you fill the "invoice no."0 -
Belias wrote:I think the real problem is: "how did you put 'NFVR00002' in your personalized (or english local) field invoice no."?
If the invoice does not exists, we have 2 possibilities:
- the program failed to assign a correct "invoice no."
- someone deleted the sales invoice header
For the second case, you can use david cox's solution, otherwise, you have to investigate how do you fill the "invoice no."
But we have answered the 'GET Error' question
Is this the best method, well not really, because if there are Value Entries then it would be easy to return the Invoice Number or possibly Numbers (Part Invoiced) for an Item Ledger from them rather than using this field, something like this.ValueEntry.RESET; ValueEntry.SETCURRENTKEY("Item Ledger Entry No."); ValueEntry.SETRANGE("Item Ledger Entry No.","Entry No."); ValueEntry.SETFILTER("Invoiced Quantity",'<>0'); IF ValueEntry.FINDFIRST THEN REPEAT IF (NOT TempInvSalesHeader.GET(ValueEntry."Document No.")) AND (InvSalesHeader.GET(ValueEntry."Document No.")) THEN BEGIN TempInvSalesHeader := InvSalesHeader; TempInvSalesHeader.INSERT; END; UNTIL ValueEntry.NEXT=0;
We do not know what this report is for, or why there is a need to return the Sales Invoice Header, I cannot see how this might be used but if the question gave a scenario of what the report would be used for, we might be able to suggest a better way or a standard report that could be modified.
DavidAnalyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com0 -
mohana_cse06 wrote:cavalcanti_space wrote:IF NOT TempInvSalesHeader.GET("Invoice No.") THEN BEGIN
InvSalesHeader.GET("Invoice No.");
Always use get with IF like in 1st line.
Yes, you're right David...I was questioning also the "Always" word of this post...I think that was good to clarify the "GET" error behaviour...and what's in my opinion the best use of it..0 -
Belias wrote:mohana_cse06 wrote:cavalcanti_space wrote:IF NOT TempInvSalesHeader.GET("Invoice No.") THEN BEGIN
InvSalesHeader.GET("Invoice No.");
Always use get with IF like in 1st line.
Yes, you're right David...I was questioning also the "Always" word of this post...I think that was good to clarify the "GET" error behaviour...and what's in my opinion the best use of it..
me also answered for 'GET Error' question0 -
I have used David´s suggestion and it is working
Cheers0
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