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
0
Answers
Always use get with IF like in 1st line.
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
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 yours
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
for this, i have given that solution.
if u have anyother solution for this please let us know.
thanks in advance
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
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 error
There ya go!
David
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com
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."
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
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.
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.
David
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com
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..
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
me also answered for 'GET Error' question
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
Cheers