I'm developing a plugin that adds a factbox to the Purchase Invoice page. In this factbox, I want to request external REST AI and render some returned data.
1) How to pass the main page Document No. (Purchase Invoice number) into the factbox?
2) Can data be rendered from an external API without creating an intermediate table? Currently, I query an external API and put everything into the "External API Data" table to render it in a factbox. But I want to get rid of this table and display data directly from an external API.
My FactBox:
page 50105 "LL Attachment List Factbox"
{
Caption = 'Documents';
PageType = ListPart;
DeleteAllowed = false;
DelayedInsert = true;
InsertAllowed = false;
SourceTable = "External API Data";
layout
{
area(content)
{
repeater(Group)
{
field(Id; Rec."Number")
{
Caption = 'Number';
ApplicationArea = Basic, Suite;
ToolTip = 'Specifies the number of the attached file.';
Width = 30;
trigger OnDrillDown()
begin
Hyperlink(Rec."Url");
end;
}
}
}
}
actions
{
area(Processing)
{
action(RefreshFromAPI)
{
ApplicationArea = All;
Caption = 'Refresh Data';
Image = RefreshLines;
Promoted = true;
PromotedCategory = Process;
PromotedIsBig = true;
ToolTip = 'Refresh data from the external API.';
trigger OnAction()
var
APIHelper: Codeunit "Handler";
begin
// TODO: Pass actual Purchase Invoice number here
APIHelper.FetchAPIData('IR-PINV0000001951');
CurrPage.Update(false);
end;
}
}
}
}