Result Matrix

Calculation results for a line item can be displayed also as a data table (matrix). This type of result can be used in many places in the application, such as Dashboards, Quotes, Price Lists, etc.

The result matrix is defined in the calculation logic.

Example 1

The following example displays rows for three different customer groups and for each customer it displays the ID, name and the net margin:

def resultMatrix = api.newMatrix("Customer Id","Name","Net Margin %") resultMatrix.addRow([ "Customer Id" : "C1", "Name" : "Enduser", "Net Margin %" : 10.4 ]) resultMatrix.addRow([ "Customer Id" : "C2", "Name" : "Restaurant", "Net Margin %" : 4.4 ]) resultMatrix.addRow([ "Customer Id" : "C3", "Name" : "Industry" , "Net Margin %" : 1.4 ]) resultMatrix.setPreferenceName("My Preference") //sets (creates) a view preference for this matrix return resultMatrix

When you run the logic in Quoting, the result matrix will appear in the Calculation Results:

After clicking on the Show button, the complete matrix will display in a modal window:

Example 2

In this example we find first 10 products and display their Sku and price in a result matrix with two columns for which we set the data format:

def lines = api.find("P", 0, 10, null, ["sku", "Price"]) return api.newMatrix() .withColumnFormats([ "sku" : FieldFormatType.TEXT, "Price": FieldFormatType.MONEY_EUR ]).withRows(lines)

View Preferences

You can customize the layout and save it as a preference.

To be able to create preferences, you must set the name of the preference (and this way to create it) in the matrix element in the calculation logic. The method to be used is called setPreferenceName. You can set the same preference name to several matrixes if you wish them to share the same layout. Once the preference is created, you can work with it like with any other preference.

You can also purposely disable saving matrix preferences if the matrix is part of a dashboard and you do not want the matrix layout changes to be included in the dashboard preference. Use the method setDisablePreferences or withDisablePreferences.

Action Buttons

You can display buttons (or links) in the result matrix rows which execute an action specified in the product's calculation logic. The matrix cells can also contain URL links or images.

To add actions, links or images to the result matrix, use the ResultMatrix class methods. The following example includes several of them.

matrix.addRow([ "Item": matrix.styledCell("Red bold text", "#ff0000", "transparent", "bold"), "Quantity": 1.23456, "Price": 78.9012, "Margin %": 0.3456, "Url": "<a href=\"https://www.pricefx.com">link</a>", // optionally you can add link to a Price Grid of the given ID "Pricegrid" : matrix.linkToPriceGrid("Open Pricegrid", 2147483768, Filter.equal("currency","EUR")), // or to a Price List of the given ID "Pricelist" : matrix.linkToPriceList("Open Pricelist", 13970, null), // or to a Company Parameter of the given ID "Company Parameter" : matrix.linkToPriceParameter("Open Company Parameter", 1586182204829828), // or a to custom page (result identical to the previous) "CustomerId" : matrix.linkCell("Customer Detail", "customersPage", "CD-00001"), // or add a library images, such as Traffic, BlackTraffic or Arrow "Margin Status" : matrix.libraryImage("BlackTraffic", getTrafficColor(-0.2f)), // or add a general image "Image" : matrix.imageCell("/classic/images/grid/sampleimage.png"), //in-line actions "Revoke": matrix.backEndAction("Revoke","/pricelistmanager.revoke/14019",null,"OK","Not OK"), "Download PDF":matrix.downloadButton("Download","/pricelistmanager.fetchpdf/14019",null), //actions grouped under one button "Actions": matrix.cells("Actions", matrix.backEndAction("Revoke","/pricelistmanager.revoke/14019",null,"OK","Not OK"), matrix.downloadButton("Download","/pricelistmanager.fetchpdf/14019",null)) ])

Action on Multiple Rows

You can enable users to select several rows and click a button that will perform some action with the values of the selected rows.

With the method rowSelectionBackEndAction you can configure the action - define its ID, the logic specifying the action and the action button label.

In the referenced calculation logic, you have to define the action that will be executed. Typically, you will use the addBackendCall method.

See also an example configuration in How to Configure Dashboards with Result Matrix Click Events.

Overridable Result Matrix

You can allow users to manually override the result values in the matrix. Enable the Allow Override option for the result matrix calculation logic element.

Create a Quote from Dashboard

You can display buttons (or links) in result matrix rows which create a new Quote with pre-filled Customer values taken from the row. This way, users can quickly create Quotes while they do analytical work in dashboards.

After the Create button or link is clicked, the application opens a new tab with the Quote detail page, where the CustomerID is pre-filled (taken form the Dashboard matrix table row context). User can finish the Quote creation process in the Quoting module as usually.

Note: User must have Edit or Administer Quoting roles assigned. User will also not see Quote Types they are restricted to see by User Group settings.

Examples

Examples of Dashboard logics enabling users to create new Quotes directly from Dashboard portlets.

Link to Create Quote Based on Default Quote Type
Button to Create Quote Based on User Selected Quote Type

See also the ResultMatrix Groovy API documentation.

Found an issue in documentation? Write to us.

 
Pricefx version 13.1