Walkthrough: Creating a Cue Based on a FlowField
This walkthrough demonstrates how to add a Cue on the RoleTailored client. A Cue provides a way to graphically show the number of entities in a table and view the entities in a filtered list. For example, the Cue can show the total number of open invoices, sales orders, or credit memos. As shown in the following illustration, a Cue is an icon that depicts a stack of papers on the page, where the height of the stack indicates the approximate number of entities in an underlying table. A number value on each Cue gives the precise number of entities. The Cue provides a shortcut link to a filtered list page for displaying the entities. You can add actions to a Cue to open related tasks that a user of the Role Center will typically perform.
About This Walkthrough
This walkthrough illustrates the following tasks:
Creating the Table Field for Cue Data
Creating a Cue on a Card Page for the Role Center
Adding an Action to the Cue
Adding the Cue CardPart Page on the Role Center Page
Roles
This walkthrough demonstrates tasks that are performed by the following user roles:
Microsoft .NET developer
Microsoft Dynamics NAV developer and IT professional
Prerequisites
To complete this walkthrough, you need:
Microsoft Dynamics NAV 2015 with a developer license.
All Microsoft Dynamics NAV 2015 requirements met. For more information, see Microsoft Dynamics NAV 2013 Requirements.
The CRONUS International Ltd. demonstration database. The walkthrough uses the following objects:
Table 36, Sales Header
Page 9006, Order Processer Role Center
Page 9301, Sales Invoice List
Page 43, Sales Invoice
Story
Viktor is a software developer who is working for CRONUS International Ltd. He has been asked to add a Cue to the Role Centers of sales order processors. The Cue will show how many open sales invoices they have. To accomplish this, Viktor will create a Cue that extracts the number of open sales invoices from the Sales Header table. He will place the Cue in a part on the Order Processor Role Center page. He will also add an action that allows users to create a new sales invoice from a link on the Cue. The Cue will look similar to the illustration earlier in this document.
Creating the Table Field for Cue Data
To calculate the number of open sales invoices, Viktor creates a table that includes a FlowField that extracts data from the Sales Header table and calculates how many opens sales invoices exist. Because a table must have at least one data field, and a FlowField is based on a calculation and not considered an actual data field, Viktor adds a dummy primary key field that does not yield any data. For more information about FlowFields, see FlowFields.
To create a table for the Cue data field and set the primary key
In the Microsoft Dynamics NAV 2015 Development Environment, on the Tools menu, choose Object Designer.
Choose Table, and then choose New.
In the first empty row, in the Field Name column, enter Primary Key and set the Data type to Code.
To set the primary key, select an empty row, and then on the View menu, choose Keys.
In the Keys window, select the first line, and then in the Key column, select the AssistEdit button.
In the Field List window, select the first row, and then choose the up arrow.
Select the Primary Key field, and then choose OK until you return to the Keys window.
Close the Keys window to return to Table Designer.
To add the Cue data field as a FlowField with filters
In Table Designer, in the next empty row, in Field Name, enter Sales Invoices - Open and set the Data type to Integer.
This defines the Cue data field.
Select the Sales Invoices - Open field row, and then on the View menu, choose Properties.
In the Properties window, set the FieldClass property to FlowField.
In the CalcFormula property, choose the AssistEdit button to open the Calculation Formula window.
In the Calculation Formula window, set the Method field to Count and the Table field to Sales Header.
In the Table Filter field, choose the AssistEdit button to open the Table Filter window.
In the first line of the Table Filter window, choose the up arrow.
In the Sales Header - Field List window, select Document Type, and then choose OK to return to the Table Filter window.
In the Document Type row, set the Type column to FILTER and enter Invoice in the Value column. This filters the Sales Header table on sales invoices.
On the next empty row, and in the Field column, choose the up arrow.
In the Sales Header - Field List window, select Status, and then choose the OK button to return to the Table Filter window
In the Status row, set the Type column to FILTER and enter Open in the Value column. This filters the Sales Header table on open sales invoices.
The Table Filters window will look similar to the following illustration.
Important
You cannot define a table filter that filters explicitly on a date because you will get an error when you try to open the Cue group in the Microsoft Dynamics NAV Windows client. For example, you cannot define a field that has the Type set to CONST or FILTER and the Value set to 21/03/2011. If you do, when you try to open the Cue group from the page in the Microsoft Dynamics NAV Windows client, you get an error that states that ‘2011-03-21’ is not a valid date.
Choose the OK button until you return to the Properties window, and then close the Properties window to return to Table Designer.
To save the table
On the File menu, choose Save.
In the ID field, enter a number that will serve as a unique table identifier. For example, you can enter 50001.
Note
There are restrictions about which numbers you can use. Contact your Microsoft Certified Partner for information.
In the Name field, enter Sales Invoice Cue.
Select the Compiled check box.
Choose the OK button.
Creating a Cue on a Card Page for the Role Center
To display the Sales Invoices - Open Cue on the Role Center, Viktor creates a CardPart page type that has a CueGroup control that includes the Sales Invoices – Open field of the Sales Cue table. Viktor also needs to initialize the data field on the Cue with a record, so he adds code to the OnOpenPage trigger of the CardPart page type.
Important
The CaptionClass property on a field in a CueGroup is not supported.
Warning
While removing cues is possible when customizing the Role Center, activity items cannot be removed.
To create the CardPart page for the Sales Invoice Cue
In the Microsoft Dynamics NAV development environment, on the Tools menu, choose Object Designer.
In Object Designer, choose Page, and then choose New. The New Page window opens.
In the Table text box, choose the up arrow to open the Table List window.
Select the Sales Cue table that you created in the previous procedure, and then choose the OK button.
Choose Create blank page, and then choose OK.
The new page opens in Page Designer.
In the Caption field of the first row, which has the Type set to Container and the Subtype set to ContentArea, enter SalesCueContainer.
Select a blank row, and then on the View menu, choose Properties.
Locate the PageType property, and then set the field to CardPart.
Close the Properties window to return to Page Designer.
To add the Sales Cue on the CardPart page
In the row following the ContentArea row, set Type to Group and set SubType to CueGroup.
In the Caption column, enter Sales Invoices. The Caption value defines the heading for the Cue that appears on the Role Center.
On the next row, set the Type column to Field.
With the row selected, on the View menu, choose Field Menu.
The Field Menu window opens and displays the list of available fields from the Sales Invoice Cue table.
Select the Sales Invoices – Open field, and then choose the OK button.
In the Caption column, enter Open. The Caption value defines the text that appears below the Cue.
Page Designer should look similar to the following illustration.
To create a link from the Cue to the Sales Invoice List page for displaying the open invoices, select the Sales Invoices - Open field row, and then on the View menu, choose Properties.
In the Properties window, set the DrillDownPageID property to Sales Invoice List (9301) and choose the OK button.
Close the Properties window.
To initialize the Cue with a record when the page opens, you must add code to the page's OnOpenPage trigger. In Page Designer, select an empty row, and then on the View menu, choose C/AL Code.
In the C/AL Editor, add the following code in the OnOpenPage trigger:
RESET; IF NOT GET THEN BEGIN INIT; INSERT; END;
Close the C/AL Editor.
To save the Sales Invoice Cue CardPart page
On the File menu, choose Save.
In the ID field, enter a number that will serve as a unique page identifier. For example, you can enter 50001 for the ID.
Note
There are restrictions about which numbers you can use. Contact your Microsoft Certified Partner for information.
In the Name field, enter Sales Invoice Cue.
Select the Compiled check box.
Choose the OK button.
In Object Designer, select the page 50001, Sales Cue, and choose Run to view the page.
The Microsoft Dynamics NAV Windows client opens and displays the new page.
Adding an Action to the Cue
Viktor wants to add a link on the Cue that allows the user to create a new sales invoice. To accomplish this, he creates an action on the CueGroup control that targets the Sales Invoice page.
To add actions to the Sales Order Cue page
In Object Designer, select the Sales Cue page, and choose the Design button.
Select the row that contains the CueGroup control Sales that contains the Sales Invoices - Open Cue field.
On the View menu, choose Control Actions.
In the first row of Cue Group Action Designer, in the Caption column, enter New Sales Invoice and set the Type column to Action.
With the first row selected, on the View menu, choose Properties.
In the Properties window, set the values for the following properties:
Set the RunPageMode property to Create.
Set the RunObject property to page 43, Page Sales Invoice.
Close the Properties window, and then close Action Designer.
Save the page.
Adding the Cue CardPart Page on the Role Center Page
To display the Sales Invoice Cue on the Role Center, Viktor must add the Sales Invoice Cue CardPart page to the Role Center page for sales order processors. To do this, he adds a part to the Order Processor Role Center page that targets the new Sales Invoice Cue page.
To add the Sales Cue part page to the Role Center page
In Object Designer, choose Page to display the list of pages.
Locate page 9006, Order Processor Role Center, and then choose Design.
In Page Designer, locate the Group control in which you want to include the Sales Cue page. For example, you can place the Sales Cue page above the <Connect Online> part.
In Page Designer, select the <Connect Online> part row, and on the shortcut menu, choose New to insert a new row in the group. This will place the Sales Cue part above the <Connect Online> part.
In the new row, set the Type column to Part.
On the View menu, choose Properties.
Set the PartType property to Page.
In the PagePartID property, set the Value column to page 50009, Sales Invoice Cue.
The Sales Cue page is the CardPart page that you created earlier in this walkthrough.
Choose the OK button, and close the Properties window.
On the File menu, choose Save to save the page.
In Object Designer, with the Order Processor Role Center page selected, choose Run. Notice that the Sales Invoice Cue part is displayed in the Role Center - Order Processor Role Center column and above the Connect Online part.
See Also
Tasks
Touring the RoleTailored Client Pages
Walkthrough: Creating a Role Center