I created a new page type of API that uses the Sales Invoice Header Source. I would like to get newly inserted Record and update its value. After that display that values in alert. Currently I have an empty page after I create new Sales Invoice.
This is my code:
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;
}
After that I created a new web service inside my BC of type query that targets Sales Invoice but in postman I get 401, no matter if I use basic authentication with my admin user or Web Service App Key I generated on my admin user.
How do I connect the insert trigger action to my API Custom Page ?