How to count the number of Sales Orders for each Customer
sbilly
Posts: 231
I want to count the number of Sales Orders for each Customer in the Sales header table.
In a report based on Sales header table, in the OnPreDataItem trigger I wrote this code
Help Please
In a report based on Sales header table, in the OnPreDataItem trigger I wrote this code
SETRANGE("Document Type",1);
nbre :=0;
IF FIND('-') THEN
REPEAT
nbre := nbre +1;
UNTIL NEXT =0;
But it counts me all the sales orders and not by each customerHelp Please
0
Comments
-
There is a flow field in customer table called "Bill-To No. of Orders" or No. of Orders0
-
Right :thumbsup: and use that!mohana_cse06 wrote:There is a flow field in customer table called "Bill-To No. of Orders" or No. of Orders
But to also help you understand why it's showing the number of all orders:SETRANGE("Document Type",1); nbre :=0; IF FIND('-') THEN REPEAT nbre := nbre +1; UNTIL NEXT =0;You only are filtering out the documents of type '1' (as you use in your code - but see below), being the orders, but not filtering out the document for a specific customer. To get that working your code should be:SETRANGE("Document Type",1); SETRANGE("Sell-to Customer No.",CustomerNo); nbre :=0; IF FIND('-') THEN REPEAT nbre := nbre +1; UNTIL NEXT =0;Or even much shorterSETRANGE("Document Type","Document Type"::Order); SETRANGE("Sell-to Customer No.",CustomerNo); nbre := COUNT;where CustomerNo is of Type Code20 holding the number of the customer you want to count for.0 -
The version of Navision that I use, doesn't contain such field.mohana_cse06 wrote:There is a flow field in customer table called "Bill-To No. of Orders" or No. of Orders
I want to display the number of ordes for many customer in one , and this code is only for one customer.SETRANGE("Document Type","Document Type"::Order); SETRANGE("Sell-to Customer No.",CustomerNo); nbre := COUNT;0 -
You have to take customer dataitem first and link it to Sales Header..
You can create those fields in your version by looking at the new version..0 -
Grate, Thanks for all of you.mohana_cse06 wrote:You have to take customer dataitem first and link it to Sales Header..
You can create those fields in your version by looking at the new version..0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

