有谁知道如何将CREATE VIEW SQL语句推送到Acumatica自定义项目中?
我知道如何在SQL Management Studio中执行此操作,但通过自定义项目执行此操作对Acumatica SaaS客户非常有用。
答案 0 :(得分:0)
您应该执行以下步骤:
在Management Studio中创建SQL视图(出于演示目的,让我坚持使用简单的PositivePay视图):
CREATE VIEW [dbo].[PositivePay] AS
SELECT
APPayment.RefNbr,
APPayment.ExtRefNbr,
APRegister.DocDate,
APRegister.OrigDocAmt,
CashAccount.ExtRefNbr BankAccountID
FROM APPayment
JOIN APRegister
ON APRegister.CompanyID = APPayment.CompanyID
AND APRegister.RefNbr = APPayment.RefNbr
JOIN CashAccount
ON APPayment.CashAccountID = CashAccount.AccountID
AND APPayment.CompanyID = CashAccount.CompanyID
WHERE APPayment.CompanyID = 2 AND APPayment.DocType= 'CHK'
GO
定义新DAC的关键字段并保存更改。对于PositivePay,我们在RefNbr字段顶部为PXDBString属性设置 IsKey 为 true :
[PXDBString(15, IsUnicode = true, InputMask = "", IsKey = true)]
[PXUIField(DisplayName = "Ref Nbr")]
public string RefNbr { get; set; }
单击数据库脚本,在数据库名称中选择您的SQL视图名称,并将SQL脚本放入自定义脚本控件中下面的模式:
IF EXISTS
(
SELECT * FROM sys.views
WHERE name = 'PositivePay' AND schema_id = SCHEMA_ID('dbo')
)
DROP VIEW [dbo].[PositivePay]
GO
CREATE VIEW [dbo].[PositivePay] AS
SELECT
APPayment.RefNbr,
APPayment.ExtRefNbr,
APRegister.DocDate,
APRegister.OrigDocAmt,
CashAccount.ExtRefNbr BankAccountID
FROM APPayment
JOIN APRegister
ON APRegister.CompanyID = APPayment.CompanyID
AND APRegister.RefNbr = APPayment.RefNbr
JOIN CashAccount
ON APPayment.CashAccountID = CashAccount.AccountID
AND APPayment.CompanyID = CashAccount.CompanyID
WHERE APPayment.CompanyID = 2 AND APPayment.DocType= 'CHK'
GO