The post shared by Josh Anglesea and comment from Avinash B both will give you a great idea how to implement and where to write code.
Here I am sharing a complete code that looks something like this and contains multiple cues in it some showing count, some running report and also having RunObject property that you can use for opening page directly and using RunPageLink you can apply filters.
Here is a complete page from which you can also extract some idea:
======================= CODE STARTS HERE ==========================
page 50117 "Orders"
{
Editable = false;
ShowFilter = false;
RefreshOnActivate = true;
LinksAllowed = false;
layout
{
area(Content)
{
group(Statistics)
{
cuegroup("Actions")
{
CuegroupLayout = Wide;
field("Total Amazon Orders"; fldTotalAmazonOrders)
{
Caption = 'Total Amazon Orders';
ApplicationArea = Basic, Suite;
ToolTip = 'Total Number of Orders in Amazon';
}
field("Today Created Amazon Orders"; fldTodaysAmazonOrders)
{
Caption = 'Today''s Amazon Orders';
ApplicationArea = Basic, Suite;
ToolTip = 'Number of Orders created today in Amazon';
}
}
}
group(Processes)
{
Caption = 'Processes & Navigation';
grid(GridLayout)
{
GridLayout = Rows;
cuegroup(Creation)
{
Caption = 'Creation';
actions
{
action("Get Amazon Orders")
{
//RunObject = page "Sales Invoice";
Caption = 'Get Amazon Orders';
ToolTip = 'Get all Amazon Orders';
Image = TileNew;
trigger OnAction()
var
recAmazonSH: Record "Amazon Sales Header";
recShopLocations: Record "Shop Locations";
pageShopLocationsList: Page "Shop Locations";
cuAmazonReqHandler: Codeunit API_AmazonRequestHandler;
totalCreatedOrder: Integer;
//pageAmazonOrderList: Page "Amazon Orders";
begin
// Code to fetch Shop Details
if (gRecShop."Amazon API Key" <> '') and (gRecShop."Amazon API Password" <> '') then begin
cuAmazonReqHandler.GetAmazonOrders(gRecShop, totalCreatedOrder);
if totalCreatedOrder <> 0 then
Message('No.of new Orders from Amazon: ' + Format(totalCreatedOrder))
else
Message('No new Orders to fetch from Amazon.');
end;
end;
}
action("Get Today's Amazon Orders")
{
//RunObject = page "Sales Invoice";
Caption = 'Get Today''s Amazon Orders';
ToolTip = 'Get all Amazon Today''s Orders';
Image = TileNew;
trigger OnAction()
var
recAmazonSH: Record "Amazon Sales Header";
recShopLocations: Record "Shop Locations";
pageShopLocationsList: Page "Shop Locations";
cuAmazonReqHandler: Codeunit API_AmazonRequestHandler;
totalCreatedOrder: Integer;
//pageAmazonOrderList: Page "Amazon Orders";
begin
// Code to fetch Shop Details
if (gRecShop."Amazon API Key" <> '') and (gRecShop."Amazon API Password" <> '') then begin
cuAmazonReqHandler.GetTodayAmazonOrders(gRecShop, totalCreatedOrder);
if totalCreatedOrder <> 0 then
Message('No.of new Orders from Amazon: ' + Format(totalCreatedOrder))
else
Message('No new Orders to fetch from Amazon.');
end;
end;
}
}
}
cuegroup(Syncronization)
{
Caption = 'Sync.';
actions
{
action("Sync Amazon Order")
{
//RunObject = page "Sales Invoice";
Caption = 'Sync Amazon Order';
ToolTip = 'Sync all Amazon Order';
Image = TileNew;
Visible = false;
trigger OnAction()
var
//pageAmazonOrderList: Page "Amazon Orders";
begin
Message('This feature will come soon!');
end;
}
action("Sync Transfer Shipment for Amazon Order")
{
//RunObject = page "Sales Invoice";
Caption = 'Sync Transfer Shipment for Amazon Order';
ToolTip = 'Sync Transfer Shipment for Amazon Order';
Image = TileNew;
Visible = false;
trigger OnAction()
var
begin
Message('This feature will come soon!');
end;
}
action("Sync Fulfillment Status")
{
//RunObject = page "Sales Invoice";
Caption = 'Sync Fulfillment Status';
ToolTip = 'Sync Fulfillment Status';
Image = TileNew;
trigger OnAction()
var
recAmazonSH: Record "Amazon Sales Header";
recShopLocations: Record "Shop Locations";
pageShopLocationsList: Page "Shop Locations";
cuAmazonReqHandler: Codeunit API_AmazonRequestHandler;
recSH: Record "Sales Header";
//pageAmazonOrderList: Page "Amazon Orders";
begin
recAmazonSH.Reset();
recAmazonSH.SetRange("Shop Code", gShopCode);
if recAmazonSH.FindSet() then begin
repeat
recSH.Reset();
recSH.SetRange("No.", recAmazonSH."Sales Order No.");
if recSH.FindFirst() then begin
recSH.CalcFields("Completely Shipped");
if recSH."Combine Shipments" then begin
// Call Amazon Service to update the ORDER Fulfillment Status
if (gRecShop."Amazon API Key" <> '') and (gRecShop."Amazon API Password" <> '') then begin
////////////////---- code here
Message('Update Amazon Order Fulfillment Status. \\\------Feature will be available soon.-------');
end;
// after this Call Amazon Service to get Fulfillment Information in Fulfullment Table and Fulfillment Status
if (gRecShop."Amazon API Key" <> '') and (gRecShop."Amazon API Password" <> '') then begin
////////////////---- code here
end;
end;
end;
until recAmazonSH.Next() = 0;
end;
end;
}
}
}
cuegroup(Lists)
{
Caption = 'Navigation';
//ShowCaption = false;
// ShowAsTree = true;
actions
{
action("Amazon Order")
{
//RunObject = page "Sales Invoice";
Caption = 'Amazon Orders';
ToolTip = 'Amazon Orders List';
Image = TileNew;
RunObject = page "Amazon Orders";
}
action("Fulfilled Amazon Order")
{
//RunObject = page "Sales Invoice";
Caption = 'Fulfilled Amazon Orders';
ToolTip = 'Fulfilled Amazon Orders List';
Image = TileNew;
trigger OnAction()
begin
Message('------Feature will be available soon.-------');
end;
}
}
}
}
}
usercontrol(HideControlsEditNewDelete; HideControlsEditNewDelete)
{
ApplicationArea = All;
//Visible = false;
trigger HideControlsEditNewDeleteReady()
var
begin
CurrPage.HideControlsEditNewDelete.Hide();
end;
}
}
}
trigger OnOpenPage()
var
recCust: Record Customer;
recItems: Record Item;
begin
recCust.Reset();
recCust.FindSet();
fldTotalBCCustomers := recCust.Count;
recItems.Reset();
recItems.FindSet();
fldTotalBCItems := recItems.Count;
cuAPI_AmazonRequestHandler.CalculateOrdersTotals(fldTotalAmazonCustomers, fldTotalAmazonItems, fldTotalAmazonOrders, fldTodaysAmazonOrders, gRecShop);
end;
procedure setShop(pRec_Shop: Record Shop; pShopCode: Code[20])
var
begin
gRecShop := pRec_Shop;
gShopCode := pShopCode;
end;
var
fldTotalBCCustomers: Integer;
fldTotalBCItems: Integer;
fldTotalAmazonCustomers: Integer;
fldTotalAmazonItems: Integer;
fldTotalAmazonOrders: Integer;
fldTodaysAmazonOrders: Integer;
cuJsonMethods: Codeunit JSON_Methods;
cuAPI_AmazonRequestHandler: Codeunit API_AmazonRequestHandler;
cuAPI_AmazonResponseHandler: Codeunit API_AmazonResponseHandler;
recShop: Record Shop;
gRecShop: Record Shop;
gShopCode: Code[20];
}
======================= CODE ENDS HERE ==========================
Good Luck!