How to ignore "DataPerCompany" property?

I have a page that show info from table in which "DataPerCompany" property set to 'Yes'. But I have to get data from all companies for my page.

So how to get data from all companies but do not change "DataPerCompany" to 'No' ? may be it could be done by code or some other way

Best Answer

  • MarharytaMykytenkoMarharytaMykytenko Member Posts: 53
    edited 2020-02-17 Answer ✓
    I have resolved this problem by adding this code to the OnAfterGetCurrRecord trigger
    (variable "po_l" has Record data type and subtype is the table that have "DataPerCompany" property set to 'Yes' ):

    comp_n:= Rec."Order Company Name";
    po_l.CHANGECOMPANY(comp_n);

Answers

  • kylehardinkylehardin Member Posts: 257
    You can't ignore it - that flag changes how the data is stored in the SQL database.

    You are trying to display this in a page?

    You'll have to make a new staging table that has DataPerCompany = false, load that table in a Company record loop in OnOpenPage, and make a new page that displays the staging table.
    Kyle Hardin - ArcherPoint
  • MarharytaMykytenkoMarharytaMykytenko Member Posts: 53
    edited 2020-02-13
    kylehardin wrote: »
    You can't ignore it - that flag changes how the data is stored in the SQL database.

    You are trying to display this in a page?

    You'll have to make a new staging table that has DataPerCompany = false, load that table in a Company record loop in OnOpenPage, and make a new page that displays the staging table.


    Thank you for the answer

    So there are no way to do my task without creating new table?
    (new table must contain data from my table, doesn't it?)
    I know that it is possible to get data from all companies form table with DataPerCompany prop set to 'Yes'. But i don't know how I can produce this
  • kylehardinkylehardin Member Posts: 257
    Create your new table with datapercompany=false, and add a new column called Company Name
    You'll probably have to alter the primary key to include Company Name
    Define your new page on top of that table - it can probably use this new table as a temporary table

    Then do something like this in a codeunit

    Company.FINDSET;
    REPEAT
    TablePerCompany.CHANGECOMPANY(Company.Name);
    IF TablePerCompany.FINDSET THEN REPEAT
    BufferTable.TRANSFERFIELDS(TablePerCompany);
    BufferTable."Company Name" := Company.Name;
    BufferTable.INSERT;
    UNTIL TablePerCompany.NEXT = 0;
    UNTIL Company.NEXT = 0;
    Kyle Hardin - ArcherPoint
  • MarharytaMykytenkoMarharytaMykytenko Member Posts: 53
    kylehardin wrote: »
    Create your new table with datapercompany=false, and add a new column called Company Name
    You'll probably have to alter the primary key to include Company Name
    Define your new page on top of that table - it can probably use this new table as a temporary table

    Then do something like this in a codeunit

    Company.FINDSET;
    REPEAT
    TablePerCompany.CHANGECOMPANY(Company.Name);
    IF TablePerCompany.FINDSET THEN REPEAT
    BufferTable.TRANSFERFIELDS(TablePerCompany);
    BufferTable."Company Name" := Company.Name;
    BufferTable.INSERT;
    UNTIL TablePerCompany.NEXT = 0;
    UNTIL Company.NEXT = 0;

    Thank you for answer

    Let me know what data type have "Company" variable
  • kylehardinkylehardin Member Posts: 257
    A record for Table 2000000006
    Kyle Hardin - ArcherPoint
  • MarharytaMykytenkoMarharytaMykytenko Member Posts: 53
    edited 2020-02-17 Answer ✓
    I have resolved this problem by adding this code to the OnAfterGetCurrRecord trigger
    (variable "po_l" has Record data type and subtype is the table that have "DataPerCompany" property set to 'Yes' ):

    comp_n:= Rec."Order Company Name";
    po_l.CHANGECOMPANY(comp_n);
Sign In or Register to comment.