Performing a CHANGECOMPANY on a dataport from a form?

PaLPiTaTioNPaLPiTaTioN Member Posts: 55
edited 2004-11-29 in Navision Attain
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?

Comments

  • g_dreyerg_dreyer Member Posts: 123
    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,
    Gus
  • PaLPiTaTioNPaLPiTaTioN Member Posts: 55
    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 great :)
Sign In or Register to comment.