How to Create and Populate ResultMatrix Object
Here is a code snippet revealing the most common features:
def getTrafficColor(value) { if (value <= 0) { return "red" } else if (value > 0 && value < 0.1) { return "yellow" } else if (value >= 0.1) { return "green" } } // initialize new matrix with three columns def matrix = api.newMatrix("Item", "Quantity", "Price", "Pricegrid", "Pricelist", "Margin Status", "Image", "CustomerId") // add more columns dynamically matrix.addColumn("Margin %") matrix.addColumn("Url") // set column formats matrix.setColumnFormat("Item", FieldFormatType.TEXT) matrix.setColumnFormat("Quantity", FieldFormatType.NUMERIC_LONG) matrix.setColumnFormat("Price", FieldFormatType.MONEY_EUR) matrix.setColumnFormat("Margin %", FieldFormatType.PERCENT) matrix.setColumnFormat("Url", FieldFormatType.LINK) // allow users to filter values matrix.setEnableClientFilter(true) // add data row 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.google.com/search?q=pricefx\">link</a>", // optionally you can add link to a pricegrid of a given id "Pricegrid" : matrix.linkToPriceGrid("Open Pricegrid", 123, null), // or to a pricelist of a given id "Pricelist" : matrix.linkToPriceList("Open Pricelist", 123, null), // or a to custom page (result identical to the previous) "CustomerId" : matrix.linkCell("Open Customer", "customersPage", "123456"), // 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("/images/grid/approve.png"), ]) return matrix
If you have performance issues with large tables, avoid saving preferences with the 'Auto fit all columns' option enabled, as mentioned in the /wiki/spaces/KB/pages/616169626.
Found an issue in documentation? Write to us.