I’m trying to create a Cue Card for Sales Orders for current month. I created it for Today with no problem, but not sure of the syntax for current month? ‘orderdate = ?’
procedure MonthPSICount(): Integer
var
sales1: Record “Sales Header”;
count4: Integer;
begin
sales1.FindSet();
repeat
begin
if sales1.“Order Date” = ? then begin
count4 := count4 + 1;
end;
end;
until sales1.Next() = 0;
exit(count4)
I thought maybe I had it, but is not counting this month’s PSI’s. I think I’m doing something wrong in the ‘CalcDate(‘CM’, Today)’, I thought that was Current Month, based on Today’s date?
procedure “Monthly PSI Count”(): Integer
var
sales1: Record “sales invoice header”;
count4: Integer;
begin
sales1.FindSet();
repeat
begin
if sales1."Order Date" = CalcDate('CM', Today) then begin
count4 := count4 + 1;
end;
end;
until sales1.Next() = 0;
exit(count4)
end;
Sales orders disappear and convert to a posted document once they’ve been completely shipped and invoiced. The data for sales orders and sales invoices are in different tables in BC.
What KPI are you looking to track here? Are you looking for a total count of sales orders for a given month? Does your organization care if they’ve shipped or not? Or do you want only shipped orders or lines?
Hi Gino, thanks for responding. I’m looking for the total counto of Posted Sales Invoice for the current month. From the Sales Invoice Header table only, it doesn’t matter if they’ve shipped or not, just any Posted Sales Invoice. The code I posted gives me a result of 0, but should be around 2,000 or so
This is the field part of the equation:
field(“Monthly PSI Count”; Rec.“Monthly PSI Count”)
{
ApplicationArea = All;
DrillDownPageId = “Sales Invoice List”;
trigger OnDrillDown()
begin
page.run(143)
end;
Or here’s the whole things, the Todays SO Count and Todays PSI Count work perfectly:
pageextension 50155 SalesCueExt extends “O365 Activities”
{
layout
{
addafter(“Ongoing Sales”)
{
cuegroup(SalesOrders)
{
field(“Todays SO Count”; TodaysSOCount())
{
ApplicationArea = all;
DrillDown = true;
trigger OnDrillDown()
var
myInt: Integer;
begin
page.run(9305)
end;
}
field(TodaysPSICount; TodaysPSICount)
{
ApplicationArea = All;
DrillDown = true;
trigger OnDrillDown()
var
myInt: Integer;
begin
page.run(143)
end;
}
field(“Monthly PSI Count”; Rec.“Monthly PSI Count”)
{
ApplicationArea = All;
DrillDownPageId = “Sales Invoice List”;
trigger OnDrillDown()
begin
page.run(143)
end;
}
}
}
}
Actions
{
}
procedure TodaysSOCount(): Integer
var
sales: Record "Sales Header";
count1: Integer;
begin
sales.FindSet();
repeat
begin
if sales."Order Date" = Today then begin
count1 := count1 + 1;
end
end;
until sales.Next() = 0;
exit(count1)
end;
procedure TodaysPSICount(): Integer
var
Invoices: Record "Sales Invoice Header";
count2: Integer;
begin
Invoices.FindSet();
repeat
begin
if Invoices."Order Date" = Today then begin
count2 := count2 + 1;
end;
end;
until Invoices.Next() = 0;
exit(count2)
end;
procedure "Monthly PSI Count"(): Integer
var
sales1: Record "Sales Invoice Header";
count4: Integer;
begin
sales1.FindSet();
repeat
begin
if sales1."Order Date" = CalcDate('CM', Today) then begin
count4 := count4 + 1;
end;
end;
until sales1.Next() = 0;
exit(count4)
end;
}
tableextension 50153 CueTableExt extends “Activities Cue”
{
fields
{
field(50154; “Todays SO Count”; Text[20])
{
Caption = ‘Todays SO Count’;
}
field(50156; “Todays PSI Count”; text[20])
{
Caption = ‘Todays PSI Count’;
}
field(50157; “Month PSI Count”; Decimal)
{
Caption = ‘Month PSI Count’;
}
field(50158; “Monthly PSI Count”; text[20])
{
Caption = ‘Monthly PSI Count’;
}
}
var
myInt: Integer;
}
Hey Nick, the code posted a little weird. Do you mind sending me your AL file to: gino@genesis.support
I can go ahead and take a look.
Thanks Gino, I appreciate it, I have sent you an email.
Hey @Nick_Firth - I was able to get your code to work. I sent it back to you in an email. I hope this helps!
Thanks! Gino
Thanks Gino! I will try it out and report back, I really appreciate your help, just starting my journey, so need all the help I can get!
