Action from Dashboard

This section explains how to make a link which will perform a certain action for a given document.

image-20221206-131025.png
Dashboard Portlet with a list of Quotes in Result Matrix


Example of using the linkCell() method to create a link with an action:

Groovy
import net.pricefx.common.api.FieldFormatType
import net.pricefx.formulaengine.scripting.AppPages

def quotes = api.find("Q", 0, 10, "-uniqueName")

def resultMatrix = api.newMatrix().withColumnFormats([
  "uniqueName"    : FieldFormatType.STRING,
  "label"         : FieldFormatType.STRING,
  "expiryDate"    : FieldFormatType.DATE,
  "workflowStatus": FieldFormatType.STRING,
  "action"        : FieldFormatType.LINK
])

def getTargetPageState(itemId) {
  return [
    id      : itemId,
    tpAction: 'SUBMIT'
  ]
}

def rows = quotes.collect {
  [
    uniqueName: it.uniqueName,
    label     : it.label,
    expiryDate: it.expiryDate,
    workflowStatus: it.workflowStatus,
    action    : it.workflowStatus == "DRAFT" ?
      resultMatrix.linkCell('Submit',
                            AppPages.QC_DETAILS_PAGE,
                            getTargetPageState(it.typedId)
      ) : null
  ]
}

return resultMatrix.withRows(rows)