Changing Companies in Navision

Craig_NeedhamCraig_Needham Member Posts: 23
edited 2000-04-06 in Navision Financials
Greetings to all.

We have been trying to do somthing interesting.(and probably unusual) We are trying to write a dataport that will enter data into various tables in various companies in Navision Financials. The CompanyChange function changes the company for that particular table.

Is there a way to change the company automatically (with C/Side) and have it changed for all objects until changed back?

Any help with this will be greatly appreciated.

regards

Craig Needham
Datrix Solutions

Comments

  • TheDoubleHTheDoubleH Member Posts: 67
    As far as I know, there isn't.

    Also if you try to post a "gen. journal line" that won't work either...


    Kind Regards

    Henrik Helgesen,
    Navision Solution Developer
    Kind Regards

    Henrik Helgesen,
    President | Helgesen Consulting
    about.me | LinkedIN
  • Borislav_PopovBorislav_Popov Member Posts: 14
    What u mean by saying "various" tables ... Could u provide more explanations ... or examples [ for what u would use thedataport ]
    Regards


    [This message has been edited by Borislav Popov (edited 02-03-2000).]
  • John_TegelaarJohn_Tegelaar Member Posts: 159
    Nope, there is no "general" ChangeCompany command. You have to do the change for each and every table that is used by your own routine, but also for each and every table that is called/used by the underlying routines (and provided that the table is having DataPerCompany to Yes, of course). Be warned that core tables like Sales header/Sales line are jumping around a lot during validation of many fields.

    John
  • Craig_NeedhamCraig_Needham Member Posts: 23
    What I mean by Various Tables into Various companies is for example. Importing invoice headers and invoice lines for both Sales and Purchases. These invoice headers are for different companies, like a franchise. The dataport should read the sales header and enter it into the Sales header table in the correct company as specified by the company field from the clients data.

    All validations should take place for data integrity, but as we know validation often means jumping around to many tables to validate customer and vendor codes etc. Not all customers and vendors are the same for all companies.

    There are many other validations which are done, therefore I was hoping that there would be a way tio change the companyfor all tables in one go. Tracing all tables is one thing, but updating all the validation code for those tables is not a viable solution, it will also make upgrades a nightmare.

    I hope this helped to clear things up a bit.

    Regards

    Craig
  • MathiasMathias Member Posts: 9
    What do you mean by changing ?
    Can you change the company on the table, or do you have to change it for all the variables that point to that table ?
    My pb is : I have a dataport which change company for the sales header table, and I would like to change it for all the tables that are used in the triggers or functions called by that table.
    May I change the company on the tables in my dataport c/al, or do I have to rewrite sales header c/al to point to the right company ?
    It makes a lot of differences...
    No wrong Code,
    Just wrong Users...
  • John_TegelaarJohn_Tegelaar Member Posts: 159
    The good news for you is that only tables are company-related (unless DataPerCompany = Yes (default) was changed), but the bad news is that you have to specifically switch over with TableName.ChangeCompany(CompanyName) to make sure the data goes to the right places (see above).

    There is no equivalent in C/AL of the generic change of company as done via the menu.

    Interesting thought... anyone tried to "press some keys" (ctrl-O in special) with a macro program you can call with a SHELL command?

    John
  • Lars_WestmanLars_Westman Member Posts: 116
    There's a major drawback with CHANGECOMPANY. You can't use triggers that use company specific tables. CHANGECOMPANY is most useful for reading data in other companies or to put data in simple tables with no validation of triggers.

    Sometimes we have done the validation in one company to get all the triggers to run and afterwards push over the records in the other company.

    No one would be happier than me if we got a global CHANGECOMPANY. That would really be useful.

    //Lars Westman
  • MathiasMathias Member Posts: 9
    My question was not to know if the development I made inside a table was stored in the table or per company or something like that... <img border="0" title="" alt="" src="images/smiles/icon_smile.gif" />)

    but at that time I wondered if I could in C/AL change my company at the core level on table, or if the change of company was stored on the variable level... that is, changing the company on a table from a dataport, and having c/al code called from another object pointing to that table and still "know" the change of company made in the dataport... <img border="0" title="" alt="" src="images/smiles/icon_smile.gif" />

    I may not be clear <img border="0" title="" alt="" src="images/smiles/icon_smile.gif" /> (my english is bad)
    but in any case, it was stupid, I experienced it and can confirm the changecompany function only applies to the variable inside an object and is not stored to the basic level of object. <img border="0" title="" alt="" src="images/smiles/icon_smile.gif" />)
    my question was stupid...

    still looking for a solution...
    No wrong Code,
    Just wrong Users...
  • John_TegelaarJohn_Tegelaar Member Posts: 159
    Mathias, there are no stupid questions. Perhaps stupid answers, but that's another story :-)

    Many have been struggling with the (lack of) change company features, so your questions surely make sense.

    Let's all hope that one of the next NF versions will have this solved.

    As said in a different reply, an interesting thought is to see if a SHELL called macro program could be used to send the keystrokes to Navision to make a generic company change. Anybody tried this?

    John
  • dbdb Member Posts: 82
    I have writed macro dll for another reasons, but any way.
    With macro program are some problems:
    1. If on workstation runing more than one fin.exe instance, we need identify that fin.exe by thread or process ID. Shell cereate new thread or use the same as fin.exe? It's very easy for C/AL ? <img border="0" title="" alt="" src="images/smiles/icon_smile.gif" />

    2. Then company changed fin release all obj. We need to run dataport or Codeunit again !

    I think that there can help only Cfront. There are func to change commpany globaly. And no problems with spec chars unlike in dataport.
Sign In or Register to comment.