counting records.

lally
Member Posts: 323
Hi,
Please help. I am not much coder how to count records and it has to come in sales invoice report.
that means Example:
s. no item qty unit price amout
1 xx 1 100 100
2 yy 1 200 200
3 zz 1 100 100
so i want serial no increment that is 1, 2, 3...... depends up on records
i done some thing like this but i am not getting.
i defined variable count, data type = int
in sales Line trigger On pre dataitem count =0;
on after get record = count=count+1;
when try to save this i am getting error THE RETURN VALUE SHOULD BE USED FOR THIS FUNCTION.
please provide solution how to do this. I am learner in coding . please provide code and solution. Please explain step by step.
regards
Please help. I am not much coder how to count records and it has to come in sales invoice report.
that means Example:
s. no item qty unit price amout
1 xx 1 100 100
2 yy 1 200 200
3 zz 1 100 100
so i want serial no increment that is 1, 2, 3...... depends up on records
i done some thing like this but i am not getting.
i defined variable count, data type = int
in sales Line trigger On pre dataitem count =0;
on after get record = count=count+1;
when try to save this i am getting error THE RETURN VALUE SHOULD BE USED FOR THIS FUNCTION.
please provide solution how to do this. I am learner in coding . please provide code and solution. Please explain step by step.
regards
lally
0
Comments
-
Did you do this
count = 0 count = count + 1
or thiscount := 0 count := count + 1
The latter is the correct way. When assign values to variables you must use the := operator.
The = operator is used for comparisons and returns true or false.0 -
-
TempSalesLine.RESET;
TempSalesLine.SETRANGE(Type,SalesHeader.Type);
TempSalesLine.SETRANGE("Document No.",SalesHeader."No.");
Count:=TempSalesLine.COUNT;David Machanick
http://mibuso.com/blogs/davidmachanick/0 -
Hi
Change your variable name as count is a reserved word in NAV.
OnPreDataItem
Ser := 0;
OnAfterGetRecord
Ser := Ser + 1;
Hope this helps
Albert0 -
lally wrote:...
on after get record = count=count+1;
when try to save this i am getting error THE RETURN VALUE SHOULD BE USED FOR THIS FUNCTION....
COUNT is a reserved word in NAV, you can not use it as a variable name.
If you are in the "Sales Line" section, define a variable NoOfLines, and add the code:NoOfLines := COUNT;
that's all you need.David Singleton0 -
Thanks David Singleton,
I put u r code in sales line on pre data item and taken a report with 3 records.
what i got every record showing 3 number at begining
that 3 for Ist record
3 for 2nd record
3 for 3 rd record
I dont want like this
what i want
1 for Ist record
2 for 2nd record
3 for 3rd record.................
like this
I tried u r code on after geet record in sales line.
but it is giving same
please provide solution.
thanks in advance.lally0 -
the sales line already have a "Line No" field. Now i'm not thinking my post was so crazy.
recordno := Salesline."Line No" / 10000;
OR
On pre dataitem.recordno := 0;
onaftergetrecordrecordno := recordno + 1;
David's post is about COUNT - like your post title says.
It will give you the total amount of lines but this is not apparently what you are looking for.0 -
Thanks Savatage,
I done already in the down process same as waht u told now.
I defined variable count, data type = int
in sales invoice Line trigger On pre dataitem count =0;
i put in sales invoice on after get record = count=count+1;
when try to save this i am getting error THE RETURN VALUE SHOULD BE USED FOR THIS FUNCTION.
please provide solution how to do this. I am learner in coding . please provide code and solution. Please explain step by step.
can u explain about that line no code . where to write.
thanks in advancelally0 -
if you read davids' post above...COUNT is a reserved word in NAV, you can not use it as a variable name.
Have you tried ANY OTHER variable name?
How about myCOUNT
or
Variable name: MyCount (type integer)
onaftergetrecord add
MyCount := Salesline."Line No." / 10000;
that's it. Now make a text box & set the source to MyCount & display it on your report, or whatever you are trying to show it.0 -
thanks savatage,
i tried what u told .
But it is giving error u have specified unknown variable "lineno"
please provide solution.
thanks and regards.lally0 -
You have to declare LineNo as an integer type variable.Ufuk Asci
Pargesoft0 -
if you are putting this code on some report using the Sales Invoice Line Table then you don't need to declare it - you just need to type it correctly.
In any programming you can't just assume the program will know what you're trying to do. "Similar" is never "the same"
"Sales Invoice Line"."Line No."
or if you are using the Sales Line Table then it would look like
"Sales Line"."Line No."
In fact if you are putting the code on the same dataitem as the field you usally do not have to add the "Sales Invoice Line" or "Sales Line" part. I did that so not to confuse and to make it a bit clearer about where the data is coming from.
Maybe it's a translation thing but I would stop adding please provide solution at the end of the posts, it just doesn't sound nice, at least to me O:)
Other things to consider...
1) using the "Line No." instead of the MyCount := Mycount + 1 method is assuming your no going to do anything freaky with "Line No." in the future.
2)When you count are you just wanting to count the lines of type "Item". You make no provisions for a blank text line or g/l account, etc.
something you might want to think about0 -
see my first post :whistle:0
-
Dear Lally
Mention the following code in OnAfterGetRecord Trigger
sno := sno + 1;
This code will serve your purpose.
Anirudh
098761579980
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