ulisses
ulisses

Reputation: 1569

How to insert record in a record in another company?

I all, I have to insert a new record in a Table.

I'm in Company "A" and I have to save a new record in Company "B", from code. I know the function crosscompany changecompany , but I don't know how to use well. Do you know how I do?

My code is :

MyTable table;

changeCompany("AnotherCompany")
ttsBegin;
select forUpdate table;
    table.Field1 = "A";
table.insert();
ttsCommit;

but I save in my current company again Thanks all,

enjoy!

Upvotes: 0

Views: 1798

Answers (1)

Thomas Post
Thomas Post

Reputation: 535

I'm using AX 2009, I assume it's quite the same in AX 2012:

changeCompany('yourCompany')
{
    ttsBegin;
    select forUpdate table;
    table.Field1 = "A";
    table.insert();
    ttsCommit;
}

Upvotes: 2

Related Questions