Redirects references to table data from one company to
another.
|
[Ok :=] Record.CHANGECOMPANY([CompanyName])
|
Parameters
- Record
-
Type: Record
The record that you want to access from a table in another
company.
- CompanyName
-
Type: Text or code
The name of the company to which you want to change. If you omit
this parameter, you change back to the current company.
Property Value/Return Value
Type: Boolean
true if the company was found; otherwise,
false.
If you omit this optional return value and the company cannot be
found, a run-time error occurs. If you include the return value,
you must handle any errors.
Remarks
Example
This example shows how to use the CHANGECOMPANY
function.
|
Copy Code |
"G/L Account".CHANGECOMPANY('New Company');
"G/L Account".GET('1000');
"G/L Account".CALCFIELDS(Balance); // Calculates the balance
// for account no. 1000 in 'New Company'
"G/L Entry".CHANGECOMPANY('New Company');
"G/L Entry".SETCURRENTKEY("Entry No.","Posting Date");
"G/L Entry".SETRANGE("Entry No.",1000);
"G/L Entry".SETRANGE("Posting Date",010196D,013196D);
"G/L Entry".CALCSUMS(Amount); // Sums Amount from
// all G/L entries on account no. 1000 within the specified range,
// for 'New Company'
"G/L Entry".RESET;
"G/L Entry".FIND('+'); // Finds the largest "No." in the G/L Entry
// table in 'New Company'
"G/L Entry".DELETE; // Deletes this entry in 'New Company'
|
This example shows that after the CHANGECOMPANY
function has been called, all future references to the G/L Account
and G/L Entry tables will refer to the table data in New
Company.
This example shows that CHANGECOMPANY only changes the
company on a data level. Triggers and functions will still run in
the context of the current company.
|
Copy Code |
Rec.CHANGECOMPANY('B');
Rec.FINDFIRST;
Rec.MODIFY(TRUE);
|
If you run the code in this example from Company A, it
will modify Rec in Company B, but it will run the OnModify trigger
in Company A.
See Also