Performing a CHANGECOMPANY on a dataport from a form?

PaLPiTaTioN
Member Posts: 55
I have a form with a button. When the button is clicked, a dataport should be called for each company in the company-table. This part is already working.
The dataport that is being called in the loop, contains a dataItem which is not shared through the companies. I want to do a changecompany on that dataItem before I call the RUN-function of the dataItem from my form. Is that possible and if so, how should I do that?
The dataport that is being called in the loop, contains a dataItem which is not shared through the companies. I want to do a changecompany on that dataItem before I call the RUN-function of the dataItem from my form. Is that possible and if so, how should I do that?
0
Comments
-
Changecompany works on a per table basis. Would have been nice if you could change the company temporarily for a transaction so that all tables accessed are from the changed company.
You will need to run the dataport once, then on the dataitem that is not global, create a variable of the same record. Do a rec.changecompany(newco), and then you can set the rec = dataitemrec and do an insert or modify. Do this for each company (you can use a loop to do that).
Be careful when validating fields on this dataitem, as it validates agains tables in the current database, i.e. if you do a get on a customer no, then it will check if the customer exists in the current company, not on the changed company.
By the way... you should look into making that table global as well, if possible.
Cheers,
Gus0 -
Thank you. It took some time before my reply. I first tried some other solutions, as doing the same thing in a report, but at last I created the solution like you described it. It works great, although it's a little odd to choose a table for a dataitem and then a global record variable of the same table to do the input, due to changecompany issues. I guess I'm too new at designing dataports to fully understand it, but it works great0
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