Error calculating Flowfields.

nofirmnofirm Member Posts: 6
edited 2005-03-31 in Navision Attain
Hi there,

i am having problems calculating flowfields. in short: i have 2 companies (A and B).
Table 15 (G/L Account) has the property "DataPerCompany" set to "No".

Each company has its own set of G/L Entries (table 17 property "DataPerCompany" set to "Yes").

Now, i tried to do this:
I opened Company "A" and runned a form with the code:

"G/L Account".Reset;
"G/L Account".ChangeCompany('B');
"G/L Account".FIND('-');
"G/L Account".CalcFields("Balance at Date");
Message('Balance at Date for account %1, in Company B is %3', "G/L Account"."No.", "G/L Account"."Balance at Date");

This code was suposed to Message the user with a value of Company B but it returns the value of the currently opened company (A).

If you set DataPerCompany of table 15 to Yes this works fine, but i thought that calcfields and changecompany would do the work.

Hope you can help! Thanx!

Comments

  • g_dreyerg_dreyer Member Posts: 123
    I must admit that I am not a 100% sure, but here goes:
    If you do a changecompany on a table, then you don't change it on all tables (only for the one table), but maybe because you are calculating a flowfield (on a table that is has data per company, therefore would calculate it from the correct company data).

    Since you have changed the data per company = yes for your G/L Account, the .changecompany has no effect?

    regards,
    gus
  • DenSterDenSter Member Posts: 8,307
    flowfields will not work into other companies, even if you force a recordvariable into another company with CHANGECOMPANY. You will have to write code in the OnAfterGetRecord trigger of the form or something.

    You could also add a function to the table with a return code. This return code can then be entered into a textbox on the form (I've seen this on a list form, not on a card form), so it basically behaves like a field of the table. I'm not sure if this will work though, I haven't tested it myself. Try getting a value from another company in that function and see if that correctly shows it on the form.
  • nofirmnofirm Member Posts: 6
    hi Gus and Daniel,

    first of all: flowfields do work with other companies.

    If my tables 15 and 17 had the property DataPerCompany=Yes, everything would work ok!

    if i run table15.changecompany(CompanyA), then, if i check the balance I can see the correct value for CompanyA.

    the problem that I'm currently having is that table 15 has datapercompany set to No and if i run table15.changecompany(CompanyA), then, balance value for CompanyA is not right.

    the problem may be in Navision's Core! It's a 100% guess!
    Maybe when one runs "table.changecompany" Navision internal process checks:
    If table.datapercompany=true then
    ' really changes company
    ' pointing to another physical table
    ' pointing to another SIFT tables
    end if

    Navision's Core should be:
    If table.datapercompany=true then
    ' really changes company
    ' pointing to another physical table
    ' pointing to another SIFT tables
    else
    ' no need to change pointer of table but:
    ' pointing to another SIFT tables
    end if

    Thanx for your support!
    SS
Sign In or Register to comment.