Retrieve all company data using single xml port

Jacob1227Jacob1227 Posts: 103Member
Hi All,

I am retrieving data from four tables from a single XML port. I can able to get the records of 4 tables for the current company.

But i want to get the same for 5 companies out of 6(i have 6 companies). I know we can use CHANGECOMPANY function. But I don't know exactly where we have to use the CHANGECOMPANY in xml port triggers.

Can you please suggest me some ideas to get all the four table data for 5 companies out of 6.

Thanks in advance,
Jacob.A

Answers

  • vaprogvaprog Posts: 924Member
    You need to call CHANGECOMPANY on all records from lines with SourceType Table and also on any auxiliary record variables you might be using from your code.

    Never done this, though, so I don't know if this will work.
  • DenSterDenSter Posts: 8,134Member
    what I would try is add a dataitem for the Company table and make the other dataitems indented to the company dataitem. Then do changecompany in OnPreDataitem
  • Jacob1227Jacob1227 Posts: 103Member
    DenSter wrote: »
    what I would try is add a dataitem for the Company table and make the other dataitems indented to the company dataitem. Then do changecompany in OnPreDataitem

    Hi @DenSter ,

    I am trying as per your suggestion first for one company. But it's not working.please find the below attachments.

    Dataitem added in XMLport:

    il3sfvqwicz7.png

    Code snippet added in onprexml trigger:

    lc6sdopuju3e.png

    Please help me...

    Thanks in advance,
    Jacob.A

  • DenSterDenSter Posts: 8,134Member
    edited 2019-10-27
    The Company table is a global table, which means that it is a table that exist for all companies in the database. You don't have to do CHANGECOMPANY on the Company table, because it is one physical table that is visible from all companies.

    Most other tables are not global tables, which means that there is a physical table for each company. For instance, if you have two companies, you will have two Item tables, one for each company.

    Normally, you log into a company, and then you can only see the tables for that company. The CHANGECOMPANY command is used to be able to read the table in another company. So if you are logged into 'Company A', you can read the items from 'Company B' by doing "Item.CHANGECOMPANY('Company B')".

    What I would try is to have a dataitem for the Company table, and everything else indented to that dataitem:
    -- Company
    ---- Item
    So for each record in the company table, it will read all the records in the Item table. All you would need to do is issue a CHANGECOMPANY command for the Item table in OnPreDataitem.

    What you did wrong is changing the copany for the company table, which is not necessary. You need to change the company of the other tables.
Sign In or Register to comment.