Hello everybody,
today I want to leave a short post on how to create some custom view in Acumatica Customization if that view doesn't exist:
if not exists (select * from sysobjects where name='CustomerSelector' and xtype='V')
begin
exec (
'CREATE view [CustomerSelector] as
select Distinct b.CompanyID, cc.Phone1, a.City, a.CountryID, b.TaxRegistrationID, c.CuryID, cc.Salutation, c.CustomerClassID, b.Status
from BAccount b inner join customer c on b.BAccountID = c.BAccountID inner join [Address] a
on a.BAccountID = b.BAccountID inner join Contact cc on cc.BAccountID = b.BAccountID'
)
end
This code will create view CustomerSelector only if such view doesn't exist in Acumatica