Exchange data between company

FiammenghiFiammenghi Member Posts: 17
Hi to all,
I've a native database (Navision 4.00) with 2 company.
Is there a method to read contents of some tables of the other company ?
If so how ?

I know there is a properties of a table (data per company) that if set to no let me share the table, but this is not what I want.

Using code, I'd like to read some records of tables of the other company.

Many tahnks in advance

Fabrizio Fiammenghi

Comments

  • krikikriki Member, Moderator Posts: 9,100
    recYourTable.CHANGECOMPANY("The company You Want");
    Be carefull NOT to use triggers of the table when putting data in it.
    This because if in the triggers another record is read or written, that record will be in CURRENT company!
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • ara3nara3n Member Posts: 9,256
    Are they going to fix this in Navision 5?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • DenSterDenSter Member Posts: 8,304
    What do you mean 'fix it'? It works as designed! :mrgreen:
  • ara3nara3n Member Posts: 9,256
    Well it's screwed up design if you ask me.
    Ofcourse, your next smart answer would be, "Nobody will ask you. So don't worry"
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • kinekine Member Posts: 12,562
    In my opinion it is too complicated to have something like "context" for each record to know in which company you are in context of the original record...

    Think about it. If you want to have possibility to call C/AL from another company through some recrod, it means, that all actions called from this record must have own context in which they run (context of the second company). But it is not possible, because part of this context is for example singleinstance codeunit initialized when opening company. But because in this situation you have not opened the company, you have not correct context in which the C/AL code for the second company can run. It is not possible to provide correct context for such a code...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • DenSterDenSter Member Posts: 8,304
    ara3n wrote:
    Well it's screwed up design if you ask me.
    Ofcourse, your next smart answer would be, "Nobody will ask you. So don't worry"
    No if you'd ask me seriously I would say it's screwed up alright, VALIDATE should work after you change company, a table object's variables should simply inherit the company of the record variable. Man would that ever make my job easier...

    The big green smiley face at the end of my comment should clue you in that I was joking.
  • kinekine Member Posts: 12,562
    Yes, but inheriting the variables is not enough to have consistent context (think for example about some SingleInstance CU, which is activated on login and you need some values from there to validate some field...).
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.