Creating personalised Caller Card factboxes
Creating the factbox
This documentation explains how to create a custom Factbox for the Phone Connect Caller Card and how to link it to the Caller Cards.
We will start by creating a custom Factbox that, in this example, displays the projects associated with the respective Contact or Customer.
| AL |
|---|
| page 00002 "SIM_CTI My New Factbox"
{
ApplicationArea = All;
Caption = 'My New Factbox';
PageType = Cardpart;
layout
{
area(content)
{
group(General)
{
Caption = 'General';
field("ItemNo."; GlobalProjectAmountInteger)
{
Caption = 'Projects';
ToolTip = 'Here you can see the found Projects Entries';
// Triggered when user clicks on the field (drill-down action)
trigger OnDrillDown()
var
LocalJobListPage: Page "Job List";
begin
// Only show marked records in the Job list
GlobalRecordJob.MarkedOnly;
// Set the view of the Job List page to the marked records
LocalJobListPage.SetTableView(GlobalRecordJob);
// Run the Job List page
LocalJobListPage.RunModal();
CalcEntries();
CurrPage.Update();
end;
}
}
}
}
// Determines the relationship between a contact or customer and sets global variables accordingly
procedure CheckRelation(ParamCode: Code[20]; ParamEnumSIMCTIBusinessMappingType: Enum "SIM_CTI Business Mapping Type")
var
LocalRecordContact: Record Contact;
LocalRecordContactBusinessRelation: Record "Contact Business Relation";
begin
// Restrict business relations to those linked to customers
LocalRecordContactBusinessRelation.SetRange("Link to Table", LocalRecordContactBusinessRelation."Link to Table"::Customer);
// Handle logic based on mapping type (Contact or Customer)
case ParamEnumSIMCTIBusinessMappingType of
ParamEnumSIMCTIBusinessMappingType::Contact:
begin
// Get the contact record
LocalRecordContact.Get(ParamCode);
// Set the global contact code depending on whether the contact is part of a company
if LocalRecordContact."Company No." <> '' then
GlobalContactCode := LocalRecordContact."Company No."
else
GlobalContactCode := ParamCode;
// Find the related customer for the contact
LocalRecordContactBusinessRelation.SetRange("Contact No.", GlobalContactCode);
if LocalRecordContactBusinessRelation.FindFirst() then
GlobalCustomerCode := LocalRecordContactBusinessRelation."No.";
end;
ParamEnumSIMCTIBusinessMappingType::Customer:
begin
// If the mapping type is customer, set customer and find the related contact
GlobalCustomerCode := ParamCode;
LocalRecordContactBusinessRelation.SetRange("No.", ParamCode);
if LocalRecordContactBusinessRelation.FindFirst() then
GlobalContactCode := LocalRecordContactBusinessRelation."Contact No.";
end;
end;
// After setting the globals, calculate the job entries
CalcEntries();
end;
// Calculates the number of relevant job/project entries
procedure CalcEntries()
var
LocalRecordContact: Record Contact; // Local variable for looping through contacts
begin
GlobalProjectAmountInteger := 0; // Reset project counter
if GlobalContactCode <> '' then begin
// Filter contacts based on the stored company number
LocalRecordContact.SetRange("Company No.", GlobalContactCode);
if LocalRecordContact.FindSet() then
repeat
// Apply customer filter if set
if GlobalCustomerCode <> '' then
GlobalRecordJob.SetRange("Sell-to Customer No.", GlobalCustomerCode);
// Filter jobs by contact number
GlobalRecordJob.SetRange("Sell-to Contact No.", LocalRecordContact."No.");
// Mark matching job entries
if GlobalRecordJob.FindSet() then begin
GlobalRecordJob.Mark();
GlobalRecordJob.Reset(); // Reset filters for next loop iteration
end;
until LocalRecordContact.Next() = 0;
end;
// Reset and reapply filter to count marked jobs
GlobalRecordJob.Reset();
GlobalRecordJob.SetRange("Sell-to Customer No.", GlobalCustomerCode);
GlobalRecordJob.MarkedOnly;
// Count the marked job entries
GlobalProjectAmountInteger += GlobalRecordJob.Count;
// Refresh the page to update the field display
CurrPage.Update();
end;
var
GlobalRecordJob: Record Job; // Holds the job entries
GlobalProjectAmountInteger: Integer; // Stores the count of found jobs
GlobalCustomerCode: Code[20]; // Stores the customer code
GlobalContactCode: Code[20]; // Stores the contact code
}
|
The example code shown below demonstrates how the relationship between the Contact and the Customer is identified, and how the corresponding data for both the contact and the customer is then displayed.
Add the factbox to the caller card
Once you have created your Factbox, it needs to be linked to the desired Phone Connect Caller Card.
To do this, a new Page Extension of the corresponding Caller Card must be created.
In the example shown below, the "Call In Contact Sales" caller card is extended. Since this is a Contact caller card, the enum value is set to Contact accordingly.
| AL |
|---|
| pageextension 00001 "SIM_CTIDocu CTI" extends "SIM_CTI Call In Cont. - Sales"
{
layout
{
addafter(SIM_CTISalesFB)
{
part(NewFactbox; "SIM_CTI My New Factbox")
{
ApplicationArea = all;
}
}
}
trigger OnAfterGetCurrRecord()
var
LocalEnumSIMCTIBusinessMappingType: Enum "SIM_CTI Business Mapping Type";
begin
CurrPage.NewFactbox.Page.CheckRelation(Rec."No.", LocalEnumSIMCTIBusinessMappingType::Contact);
end;
}
|
After you have created your custom Factbox and linked it to the Caller Card, the setup is complete.
Your Factbox is now ready for seamless use.