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
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?
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.
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.
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.
Comments
CHANGECOMPANY
command
** SI ** Bert Van Gestel **
**********************
Best Regards
Dynamics NAV Developer
Are you running a report or a form?
Do you have an examle of your code?
Dynamics NAV Developer
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.
Peter
You will have to develop something to retrieve that information into a new table and display the content of that table on your form.
RIS Plus, LLC
and i thought i was onto something here.
](*,)
** SI ** Bert Van Gestel **
**********************
Dynamics NAV Developer
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.
RIS Plus, LLC
it's works ... thanks for your corroboration.
I just wondaring if I can get customers form another database.? it's possible or not ?
Best Regards
Dynamics NAV Developer
The only way i know of to do that is by making a view on the sql server.
** SI ** Bert Van Gestel **
**********************
Dynamics NAV Developer
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 **
**********************