There are three tenants in our Acumatica Instance. For the purpose of creating a SQL view, we used the below DB Script.
create or alter view ardiscountView as
select ROW_NUMBER() OVER(ORDER BY Usrdiscountcoden ASC) row,RefNbr,TranType type,Usrdiscountcoden discount,sum(CuryDiscAmt) amount from artran where Usrdiscountcoden is not null
and CompanyID=2
group by RefNbr,TranType,Usrdiscountcoden
But in here we had to hardcode the CompanyID. But we want dynamically pick the CompanyID depending on the current tenant. If you can provide a way to perform this it id highly appreciated.