Question Status

Verified
ganriver asked a question on 18 Mar 2015 11:45 AM

It's my understanding every table has DataAreaId field, so is this VendAgingReportTmp.

But, I can't see the field or browse to it , how can I display it on report.

Regards,

River

Reply
Suggested Answer
Anton Venter responded on 18 Mar 2015 12:18 PM

Hi River, in this case it does not have a DataAreaId because the SaveDataPerCompany property is set No. You can add a new custom field to the table and populate this field in code or maybe enable the SaveDataPerCompany property. I don't know what the impact is enabling the property so test first.

Reply
ganriver responded on 18 Mar 2015 2:18 PM

Hi Anton,

I enabled property, but, the DataAreaId is still not showing up in dataset in report after refresh. So I add a field for it.

my question is this, once it's enabled, it means the table can save data just for one company, right?

Thanks,

Reply
Anton Venter responded on 18 Mar 2015 2:27 PM

Hi River, yes so it is better to add a field for this.

Reply
ganriver responded on 18 Mar 2015 3:56 PM

Hi Anton,

I have related question. In VendTable, which field indicates which company the record belongs to? DataAreaId? at least in our table, DataAreaId are all same. But, clearly it's not the case.

Reply
Dominic Lee responded on 18 Mar 2015 9:31 PM

SaveDataPerCompany = Yes means data is saved per company (not just one company). So 2 different companies can have Vendor using the same account number despite AccountIdx (which contains the AccountNum field only) does not allow duplicates.

This is because at the backend DataAreaId is added to all indexes and with SaveDataPerCompany set to yes a different value will be store in the VendTable records.

So to your question, DataAreaId should indicate which company the record is in.

Note that if you check from the table browser it only shows record in the current company. That maybe the reason you see that all dataAreaId are the same.

Try do a simple query on VendTable in SSMS instead.

kind regards,

Dominic Lee

My blog | PBC

This forum post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

Reply
Suggested Answer
Anton Venter responded on 19 Mar 2015 1:15 AM

Hi River, like Dominic mentioned, the DataAreaId fieds indicates which company the record belongs to, this allows multiple companies in the system. You can use the crossCompany or changeCompany keywords in a select statement or use the AllowCrossCompany property on a query in the AOT to query data across companies.

Reply
ganriver responded on 19 Mar 2015 9:13 AM

Hi Dominic,

I did check in SSMS, it's all same in VendTable, and the value is no where found in company list, is it virtual company?

Reply
ganriver responded on 19 Mar 2015 9:28 AM

Hi Anton,

This question goes back to a report, vendagingreport we want to customize.

We want to run it across companies.

There are complex queries behind it to populate temp table.

Tried many things, latest, I used changecompany, put those queries/methods inside loop,

but, it crashed in the second company, is there any refresh method/process need to be called after changecompany?

Many thanks.

River

Reply
Dominic Lee responded on 19 Mar 2015 10:00 AM

In SSMS, do a

SELECT *

FROM DATAAREA

The DataAreaId code should be there. And you can check the IsVirtual flag to see if it's a virtual company

kind regards,

Dominic Lee

My blog | PBC

This forum post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

Reply
ganriver responded on 19 Mar 2015 10:21 AM

yeah, as I suspected, it's virtual company.

Question is, in VendTable, DataAreaId is this Virtual company, when you run query on this table, how it works?

Reply
Anton Venter responded on 19 Mar 2015 10:22 AM

There's no refresh required for changeCompany. Do you have a different method that contains the changeCompany code or do you have it in the main loop of your code?

Reply
Anton Venter responded on 19 Mar 2015 10:24 AM

It depends on your virtual company setup, so it will act "normally" if you query from a company that's setup as a virtual company.

Reply
ganriver responded on 19 Mar 2015 10:36 AM

It's in main loop. So far, I found it crashed  in class : CustVendAgingCaculation->insertCustVendData,

Since first iteration is finished, it crashed for second company, I suspect there is memory/buffer issue here.

I tried to clear customersVendors, but, it doesn't help.

    recordInsertList = new RecordInsertList(tableNum(CustVendTransAging), true, true, true, false, true, customersVendors);
//customersVendors.clear(); while (_custVendQuery.next()) { custVendTable = _custVendQuery.get(this.getCustomerOrVendorTableId()); customersVendors.AccountNum = custVendTable.AccountNum; customersVendors.GroupId = custVendTable.GroupId; recordInsertList.add(customersVendors); } recordInsertList.insertDatabase();


Reply
ganriver responded on 19 Mar 2015 10:42 AM

or, because CustVendTransAging table's 'SaveDataPerCompany' is No?

Reply
Anton Venter responded on 19 Mar 2015 10:55 AM

What's the error message? I always write the code that contains the changeCompany code in another method with local variables.

Reply
Verified Answer
ganriver responded on 20 Mar 2015 9:26 AM

Thanks everybody, figured out.

When changecompany, need to re-initialize query, that fixed problem.

Reply
Suggested Answer
Anton Venter responded on 18 Mar 2015 12:18 PM

Hi River, in this case it does not have a DataAreaId because the SaveDataPerCompany property is set No. You can add a new custom field to the table and populate this field in code or maybe enable the SaveDataPerCompany property. I don't know what the impact is enabling the property so test first.

Reply
Suggested Answer
Anton Venter responded on 19 Mar 2015 1:15 AM

Hi River, like Dominic mentioned, the DataAreaId fieds indicates which company the record belongs to, this allows multiple companies in the system. You can use the crossCompany or changeCompany keywords in a select statement or use the AllowCrossCompany property on a query in the AOT to query data across companies.

Reply