Inserting one record in multiple company

ebrahma
Member Posts: 36
I want to insert one record in to mulitple companies when inserted in any company.Any body knows the script lines ..pls tell..
0
Comments
-
can you use DataPerCompany=No property ?®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0 -
try CHANGECOMPANY0
-
what i mean: if you want the records to be allways the same for all companies you can use DataPerCompany=no.
otherwise you shouldcreate some code using CHANGECOMPANY function...®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0 -
But see http://www.navision.net/forum/topic.asp?TOPIC_ID=9491 which advises against setting DataPerCompany = NO. In particular these two posts that I'm taking the liberty to quote here:
David Singleton:
Firstly, whilst it seems simple, it is not a good idea to make the master records (Cust, item etc) as common to all companies, it just causes too many problems. Better is to write code that syncs them between all the companies, which is a really simple bit of code.
Beaver:
I must agree to David: Setting Customer to DataPerCompany=No seems to be simple, but it surely is not.
In order to have consistent data, you must also set all the tables to DataPerCompany=No, to which fields in the customer table refer to. An example would be the Gen. Bus. Posting Group table.
If you do not do that and you set up different Posting Groups in the companies, the validation of that field in table customer will fail.
That need to make many more tables valid for all companies can lead to serious problems. Take the Payment Terms table. This is valid for customers AND vendors. If you make customers DataPerCompany=No than the Payment Terms table will have to be DataPerCompany=No as well. Then you cannot set up different payment terms for your vendors per company which you still might want to.
Synchronizing is generally the better way to do it.Alastair Farrugia0 -
I didn't say it is easy and without any concerns.
Here's also a post, where I described a bit more about DataPerCompany and what you should be aware of:
http://www.mibuso.com/forum/viewtopic.php?t=2524®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0 -
I tried using CHANGECOMPANY function ,,I am not able to get the solution rather i am not approaching the solution correctly.Can any one please give me some sample code regarding CHANGECOPANY for inserting one record from one company to all the companies in the database.
Thanks
e-Brahma0 -
create a global variable, e.g. Comp, from type record and Subtype 2000000006 "Company". In this table are all Compynies of your Database. The following example shows how one Item is inserted in all Companies.
Create a funcion with Parameter Item of Type Record an Subtype 27 Item. This Record will be inserted in all other Comanies.Comp.FIND(-'); REPEAT IF Comp.Name <> COMPANYNAME THEN BEGIN Item2.CHANGECOMPANY(Comp.Name); Item2.COPY(Item); If not Item2.insert THEN Item2.MODIFY; END; UNTIL Comp.NEXT = 0;
Attention: This Routine does NOT validate any field in the other Companies!!! If you want to do this you have to assign every single value from teim to item2 and validate the fields. But remember: The tables (global and local records) which were refered to in the Validate-triggers belong to the active company!!! You have to use CHANGECOMPANY for this tables, too!!! To find all neccessary tables is a hard work. But this is your only way to use this function!
Hope this helps.
Regards,
Frank0 -
your code is working great!
Thanxs0
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