How to retrieve all company data from one company

Jacob1227
Member Posts: 128
Hi All,
I have created one xml port which used to export one company data from one table( table A). But now I want to retrieve all the company details from that table'A' without changing the company.
Ex: Table 'A' - has all company(Cronus usa,Cronus canada...etc) data. I am accessing canada USA,I want to export all the company data without changing to another the company
Can you please help me to do this.
Thanks in advance,
Jacob.A
I have created one xml port which used to export one company data from one table( table A). But now I want to retrieve all the company details from that table'A' without changing the company.
Ex: Table 'A' - has all company(Cronus usa,Cronus canada...etc) data. I am accessing canada USA,I want to export all the company data without changing to another the company
Can you please help me to do this.
Thanks in advance,
Jacob.A
0
Best Answer
-
There's a system table 2000000006 Company. If you add a variable (name: Company, type: Record, subtype: 2000000006) for it, your code could look something like:
IF Company.FINDSET THEN BEGIN REPEAT TableA.CHANGECOMPANY(Company.Name); [do stuff with TableA] UNTIL Company.NEXT = 0; END;
5
Answers
-
Hi, you can use the function CHNAGECOMPANY and then repeat it on eachy company in your export0
-
Thanks Brax,
Can you please provide me some code snippet for this.0 -
Why don't you simply copy the company?0
-
You have two Variables that is Record TableA
TableA1 and TableA2
When You use these table variables they will use data from current company
TableA1.FINDFIRST;
REPEAT
.....
UNTIL TableA1.NEXT=0;
But when You use
TableA2.CHANGECOMPANY('Other database company name');
TableA2.FINDFIRST;
REPEAT
.....
UNTIL TableA2.NEXT=0;
You will get all records from TableA, but from other (not current) company ;o)
In XML port it can be two names where OnPreXMLItem You can use this CHANGECOMPANY0 -
You have two Variables that is Record TableA
TableA1 and TableA2
When You use these table variables they will use data from current company
TableA1.FINDFIRST;
REPEAT
.....
UNTIL TableA1.NEXT=0;
But when You use
TableA2.CHANGECOMPANY('Other database company name');
TableA2.FINDFIRST;
REPEAT
.....
UNTIL TableA2.NEXT=0;
You will get all records from TableA, but from other (not current) company ;o)
In XML port it can be two names where OnPreXMLItem You can use this CHANGECOMPANY
Thanks for your suggestion.
I have more than 20 companies in my environment.
So is this possible to get all company data without hard coding individual company name company name?
0 -
There's a system table 2000000006 Company. If you add a variable (name: Company, type: Record, subtype: 2000000006) for it, your code could look something like:
IF Company.FINDSET THEN BEGIN REPEAT TableA.CHANGECOMPANY(Company.Name); [do stuff with TableA] UNTIL Company.NEXT = 0; END;
5 -
Hi Shaihulud,
It seems to be working.
Thank you so much
Warm regards,
Jacob.A0 -
Hi @ShaiHulud ,
Where I have to use the code snippet in xml port?
when i was trying the code in codeunit ther it works.
But in xml port it didnot work. I was putting the code in onprexmlport() trigger.
Please help me with the correct trigger to put the code.and also i want to get the data for only five companies not for all 20 companies.
Guide me,,,
Thanks,
Jacob.A0 -
Hi @ShaiHulud, Can you please help me on this.0
-
Hi @ShaiHulud, Can you please help me on this.
This entirely depends on how your XML port is structured. I had actually written a reply to you earlier, but Mibuso for some reason dumped it into "waiting for approval".
Anyway, in short, you could have a codeunit that switches companies on your chosen table, and that passes that table to an XMLPort. Something along the lines ofCompany.SETFILTER(Name, 'whatever filter you make to select only those 5 companies'); IF Company.FINDSET THEN BEGIN REPEAT TableA.CHANGECOMPANY(Company.Name); XMLport.RUN (50000, FALSE, FALSE, TableA); //replace 50000 with your XMLPort No. UNTIL Company.NEXT = 0; END;
Again, that depends entirely on how your XMLPort is structured. The approach I suggest depends on you having your TableA as the "root" record in the XMLPort.0
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