Changecompany

Viji_GanesanViji_Ganesan Member Posts: 37
Hi All,

I am using changecompany function to get the records from other companies,
while insterting those in temp record variable, it keep says the record already exist.
say for "G/L Entry" table, if i get the data of other company thro changecompany and inserting it in the temp variable and display it. while inserting it throws error as
"G/L Entry Entry No. '1' already exists".
Kindly help me.

Regards,
Viji.

Comments

  • ara3nara3n Member Posts: 9,256
    make sure your variable is temporary.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • DenSterDenSter Member Posts: 8,305
    Makes sense though doesn't it. You go into one company, changes are that G/L Entry number 1 exists. Then you go to another company, changes are that that company also has a G/L Entry number 1. If you are going to combine G/L Entry records from multiple companies into one variable, you need to make sure that the primary key of your temporary record variable includes the company name, or something else that signifies the identity of the company.
  • bbrownbbrown Member Posts: 3,268
    Remember that CHANGECOMPANY only impacts the record variable for which it is called. All other record variables still refer to the current company.
    There are no bugs - only undocumented features.
  • garakgarak Member Posts: 3,263
    Be careful with changecompany. Only the Rec Variable on which you work is changed. So for example you make a validate on a field and in this field is source the source is fired on the actual company not on the changed company! Also never make validates on a temporary table if there is source in the onvalidate and there are other tables filled / modified.

    so for your problem: You have the G/L as temp table and insert Account 123 for the first company. Now you change the company and there you will also insert in your temp. table the account 123 <- but this exist. so use a self defined table as temporary (for example you create your own with all needed fields so you can also use this table in other cases) and there you store company name and GL acc.

    regards
    Do you make it right, it works too!
Sign In or Register to comment.