Take customer's name from all companies
abnainas
Member Posts: 174
Dear All.
I have a NAV database that consist of 5 companies. for each company has it's own customers. The issue is that can I retrieve all the customers from all companies in one shot. #-o
I have a NAV database that consist of 5 companies. for each company has it's own customers. The issue is that can I retrieve all the customers from all companies in one shot. #-o
Ahmad Bani Naser
Dynamics NAV Developer
Dynamics NAV Developer
0
Comments
-
try the
CHANGECOMPANY
command**********************
** SI ** Bert Van Gestel **
**********************0 -
Thanks... i use the CHANGECOMPANY function and it is worked. But it give me the customers for one company. I want all customers in all compaines.
Best RegardsAhmad Bani Naser
Dynamics NAV Developer0 -
Remember that after you changecompany you must then reset your filters and set the range again.
Are you running a report or a form?
Do you have an examle of your code?0 -
ThanksAhmad Bani Naser
Dynamics NAV Developer0 -
To help one of your problems, then you should try looking at the Company table. Simply loop through it, and then you don't need to hardcode company names in your code.
However, it seems you try to show customers from all companies in one list, is that correct?
Then you will have to create a new table, unless you know (or is allowed to assume) that no Customer No. is used in more than one company. Then create a new table with primary key Company,"Customer No."
Then let your code loop through the companies and for each company loop through customers and fill a temporary record variable. But if you have a lot of customers it might take quite some time. A different solution could be making the new table DataPerCompany=No and ensure it was updated when the customers are updated. That would be quite a big task, but not impossible. If you are using SQL, you could create a SQL View. However, then I still think you'll need to hardcode the companynames.
I'll recommend not using the standard customer list form, eventhough you might get told that no customer no. is reused in multiple companies. All the functions and sub-views will be messed up when you try to do anything with a customer from a different company.
Depending what your client is trying to gain from you help, the solution might be to mark the Customer table as DataPerCompany=No.Regards
Peter0 -
It's not possible to list all customers from all companies in one list. A form can only be linked to one table, and each company has its own Customer table.
You will have to develop something to retrieve that information into a new table and display the content of that table on your form.0 -
damn,
and i thought i was onto something here.
](*,)**********************
** SI ** Bert Van Gestel **
**********************0 -
ThanksAhmad Bani Naser
Dynamics NAV Developer0 -
Something like this:
IF Company.FINDSET THEN BEGIN REPEAT Customer.CHANGECOMPANY(Company.Name); IF Customer.FINDSET THEN REPEAT TempCustomer.INIT; // set all fields, use transferfields or copy or whatever else works TempCustomer.INSERT; UNTIL Customer.NEXT = 0; UNTIL Company.NEXT = 0; END;I'm writing this off hand, have not tested it.
It looks like you should read the application designers guide and maybe even the developer training material, because it doesn't look like you understand record navigation in C/AL code yet.0 -
Dear DenSter
it's works ... thanks for your corroboration.
I just wondaring if I can get customers form another database.? it's possible or not ?
Best RegardsAhmad Bani Naser
Dynamics NAV Developer0 -
Hahaha, now you are pushing it

The only way i know of to do that is by making a view on the sql server.**********************
** SI ** Bert Van Gestel **
**********************0 -
:-$Ahmad Bani Naser
Dynamics NAV Developer0 -
I mean that you are making it harder and harder on yourself.
And me, the joyfull person that i am, i thought i would give you the answer with a little laugh.
So no need to search for a deaper meaning , is this a cultural issue for you or did you just not understand, i'm interested?**********************
** SI ** Bert Van Gestel **
**********************0
Categories
- All Categories
- 73 General
- 73 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 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

