Renaming G/L Account using CHANGECOMPANY does not rename related tables in Nav 2013

Hello,

I’ve run into an issue trying to use the CHANGECOMPANY function to synchronize Renames across companies for Table 15 in Nav 2013. The same code works fine in Nav2009 R2, both Classic and RTC. Below is the test code I’m using:

G/L Account-OnRename

“Last Date Modified” := TODAY;

IF NOT IsSynch THEN BEGIN

IF CostAccSetup.READPERMISSION THEN
CostAccMgt.UpdateCostTypeFromGLAcc(Rec,xRec,3);

GLAcct2.CHANGECOMPANY(‘CRONUS USA, Inc.’);

GLAcct2.SetSynch(TRUE);
IF GLAcct2.GET(xRec.“No.”) THEN
GLAcct2.RENAME(“No.”);

END;
//IF CostAccSetup.READPERMISSION THEN
// CostAccMgt.UpdateCostTypeFromGLAcc(Rec,xRec,3);

For the purpose of the test I’m renaming in a specific named company. The Chart of Accounts record gets renamed in the target company but the G/L Entry and other related tables do not get renamed. I have the same issue in Nav 2013 and Nav2013 R2 rollup 4 but not, as I said, in Nav2009 R2. The user I’m logged in as has SUPER permission.

Does anybody have any idea what is happening here?

Thanks,

Ken Moore

I would actually expect that to fail in ANY version of NAV. You’re on NAV 2013, so look into using background sessions for this. You can use STARTSESSION in any other company, and the entire session lives in that other company. Create a codeunit that accepts a record, figure out a way to send in the new number and let the codeunit do the RENAME.

Based on my admittedly limited understanding of how CHANGECOMPANY works I would have thought that it wouldn’t work either. Except, as I said, it does in 2009. I haven’t tried with other versions. This is a client customization that is being moved to 2013 so I was pretty surprised to find that it didn’t work. Made me wonder if the client had been causing problems in their DB all along but that’s not the case.

Your idea for STARTSESSION looks like exactly what I need. I had considered rewriting it to use web services but this looks like it might be faster.

Thanks a lot.

You’re welcome. I think STARTSESSION only works within the same database though, so if you need to go across databases, web services is probably a cleaner solution.