我创建了一种新的页面类型的 API,它使用销售发票标头源。我想获取新插入的记录并更新其值。之后在警报中显示该值。目前我在创建新的销售发票后有一个空白页面。
这是我的代码:
page 50105 "Custom Invoice API" {
PageType = API;
Caption = 'Custom Sales Invoice Header API';
APIPublisher = 'xy';
APIVersion = 'beta';
APIGroup = 'customsalesinvoiceheader';
EntityName = 'salesInvoiceHeader';
EntitySetName = 'salesInvoiceHeaders';
SourceTable = "Sales Invoice Header";
DelayedInsert = true;
layout
{
area(Content)
{
repeater(GroupName)
{
field(id; "No.")
{
Caption = 'No.';
}
field(name; "Sell-to Customer Name")
{
Caption = 'Customer Name';
}
field(address; "Sell-to Address")
{
Caption = 'Sell-to Adress';
}
field(shipdate; "Shipment Date")
{
Caption = 'Shipment Date';
}
}
}
}
trigger OnInsertRecord(BelowxRec: Boolean): Boolean
begin
Insert(true);
Message(readInvoice());
updateInvoice();
exit(true);
end;
procedure readInvoice(): Text
var
currentInvoice: Record "Sales Invoice Header";
begin
exit(currentInvoice."No." + ' ' + currentInvoice."Sell-to Customer Name" + ' ' + currentInvoice."Sell-to Address" + ' ' + Format(currentInvoice."Shipment Date"));
end;
procedure updateInvoice()
var
currentInvoice: Record "Sales Invoice Header";
begin
currentInvoice."Shipment Date" := DMY2Date(19, 6, 2020);
end;
}
之后,我在我的 BC 类型查询中创建了一个新的 Web 服务,该查询针对销售发票,但在邮递员中我得到 401,无论我是对我的管理员用户使用基本身份验证还是在我的管理员用户上生成的 Web 服务应用程序密钥。
如何将插入触发器操作连接到我的 API 自定义页面?