In this post I will show you two ways you can create cues. One calculated by a variable and the other by a flowfield.

For both examples we will show the number of blocked customers in the database. The colour of the cue will also change depending on a predefine threshold.

Variable Calculation

A role center cue is just a page part in which we define a cuegroup.

For this example the ‘BlockedCustomersVar’ will be calculated on the ‘OnAfterGetCurrRecord’ trigger. Also if the number of blocked customer is greater than 2 the cue will change colour. For this first example everything is setup by code.

In order to dive into the data we must define the ‘OnDrillDown’ trigger also manually :

The page part can be embeded into the role center just like following:

FlowField Calculation

As Microsoft suggests:

https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-cues-action-tiles

This method is scalable. It´s based on a ‘setup table’ (one record table) in which you can define every flowfield you´d like to show later.

In this example the flowfield is calculated as follows:

In the page we just need to show the field. No need to define the ‘OnDrillDown’ trigger as the flowfield let us do it. Just remember to add the ‘SourceTable’ property:

What about the thresholds?

The best part is that we can access the cue setup and define our own thresholds for each flowfield on the table. This way every user can have the possibilty to define their own limits.
In order to acces the cue setup we can look for the ‘Cue Setup’ page or add an action to the cue page like the following:

This way when a user defines a threshold via action it will be saved only for this particular user:

Conclusion

Personally, I´d use the variable method for rather more complex algorithms although be aware of the performance. However, if you can define the calculation by a flowfield then a cue table is the way to go.

As you can see in the video below both ways works the same:

Bonus

You can define the ‘CuegroupLayout’ property to ‘wide’ for larger numbers and it will look like the following:

Source code:

table 50103 "CustomCueTable"
{
    DataClassification = ToBeClassified;

    fields
    {
        field(1; PrimaryKey; Code[20])
        {
            NotBlank = true;
            DataClassification = ToBeClassified;
        }
        field(2; BlockedCustomers; Integer)
        {
            Editable = false;
            FieldClass = FlowField;
            CalcFormula = count(Customer where(Blocked = filter(All)));
        }
    }

    keys
    {
        key(PK; PrimaryKey)
        {
            Clustered = true;
        }
    }

    procedure InsertIfNotExists()
    begin
        Rec.Reset();
        if not Rec.Get() then begin
            Rec.Init();
            Rec.Insert();
        end;
    end;
}
page 50113 "CustomCue"
{
    PageType = CardPart;
    SourceTable = CustomCueTable;
    RefreshOnActivate = true;

    layout
    {
        area(Content)
        {
            cuegroup(cuegroup1)
            {
                Caption = 'Blocked Customers';

                field(BlockedCustomers; BlockedCustomersVar)
                {
                    Caption = 'By Variable';
                    ApplicationArea = all;
                    StyleExpr = Style;

                    trigger OnDrillDown()
                    var
                        Cust: Record Customer;
                        CustomerList: Page "Customer List";
                    begin
                        Cust.SetRange(Blocked, Cust.Blocked::All);
                        CustomerList.SetTableView(Cust);
                        CustomerList.Run();
                    end;
                }

                field(BlockedCustomersFlowField; Rec.BlockedCustomers)
                {
                    Caption = 'By FlowField';
                    ApplicationArea = all;
                }
            }
        }
    }

    actions
    {
        area(Processing)
        {
            action("Set Up Cues")
            {
                ApplicationArea = All;
                Image = Setup;

                trigger OnAction()
                var
                    CuesAndKpis: Codeunit "Cues And KPIs";
                    CueRecordRef: RecordRef;
                begin
                    CueRecordRef.GetTable(Rec);
                    CuesAndKpis.OpenCustomizePageForCurrentUser(CueRecordRef.Number);
                end;
            }
        }
    }

    trigger OnOpenPage()
    begin
        Rec.InsertIfNotExists();
    end;

    trigger OnAfterGetCurrRecord()
    var
        Cust: Record Customer;
    begin
        Cust.SetRange(Blocked, Cust.Blocked::All);
        BlockedCustomersVar := Cust.Count();

        if BlockedCustomersVar > 2 then
            Style := 'Unfavorable';
    end;


    var
        BlockedCustomersVar: Integer;
        Style: Text;

}

Hope you find it useful.

2 Ways To Create Cues In Business Central

Post navigation


One thought on “2 Ways To Create Cues In Business Central

Leave a Reply

Your email address will not be published. Required fields are marked *

WordPress Cookie Plugin by Real Cookie Banner