I have a query that sums up some general ledger entries, because it is faster to use a query than to use a findset repeat until contruct.
But in Company X I want to change to company Y, and then read the query, but I cannot figure out how to change the record in the query. It still runs for Company X.
the query looks like this
query 50000 "MyQuery"
{
Access = Internal;
Caption = 'MyQuery';
QueryType = Normal;
DataAccessIntent = ReadOnly;
elements
{
dataitem(GLAccount; "G/L Account")
{
column(No_; "No.")
{ }
column(Account_Type; "Account Type")
{
}
column(IncomeBalance; "Income/Balance")
{
}
filter(Dimension_Set_ID_Filter; "Dimension Set ID Filter")
{
}
dataitem(GLEntry; "G/L Entry")
{
DataItemLink = "G/L Account No." = GLAccount."No.";
column(G_L_Account_No_; "G/L Account No.")
{ }
column(G_L_Account_Name; "G/L Account Name")
{ }
column(Dimension_Set_ID; "Dimension Set ID")
{ }
column(Amount; Amount)
{
Method = Sum;
}
filter(Posting_Date; "Posting Date")
{
}
}
}
}
trigger OnBeforeOpen()
begin
end;
}
Any ideas?
You cannot do that because you cannot create a variable for the record that you use in the dataitem
Here I am not able to create a var for "G/L Account" as a global or local variable that I can use in the query
query 50000 "MyQuery"
{
Access = Internal;
Caption = 'MyQuery';
QueryType = Normal;
DataAccessIntent = ReadOnly;
elements
{
dataitem(GLAccount; "G/L Account")
{
column(No_; "No.")
{ }
column(Account_Type; "Account Type")
{
}
column(IncomeBalance; "Income/Balance")
{
}
filter(Dimension_Set_ID_Filter; "Dimension Set ID Filter")
{
}
You can use StartSession for this.
See learn.microsoft.com/.../session-startsession-integer-integer-string-table-duration-method
change company for the source table onBeforeOpenRun trigger then run
I don't think you have read the question.
How would you change company for a table in a query. It is not possible
You need use change company for source table like
GLAccount.ChangeCompany('Test');
This does not work, as you are only changing company for the CompInfo variable but not for the Query itself.
Even though I try what you outline, it still runs in the company the user is in. :-(
Hi, As far as I know, there is no company property in Query. When using it, you can call the ChangeCompany method before opening it and it should work.
More details:
Hope this helps.
Thanks.
ZHU
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,228 Super User 2024 Season 2
Martin Dráb 230,056 Most Valuable Professional
nmaenpaa 101,156