One of the action you can add on to ResultMatrix is to have a button , which will navigate users to another page to perform an action with selected the list of items selected from the matrix.
...
Before the button performs the action - To perform the action, there has to be a definition of the action – it is either a Deep deep link or a Context context link. To perform the action, it needs the definition of the action - so it will call the BackEndAction Logic, The BackEndAction logic is called to retrieve the definition.
...
Logic Nature: generic (null)
Logic Type: Calculation/Pricing
Execution Types
Standard - the logic – Logic is only executed via normal execution.
Information provided to the logic
Inputs:
InputMatrix input with a list of items selected in the ResultMatrix. The name of this input is set in the call of method rowSelectionBackEndAction()when calling the rowSelectionBackEndAction() method.
The ResultMatrix can also pass additional inputs to this logic, via calling the method BackEndAction.addFormulaInput().
Expected logic execution outcome
The first visible element (with Display Mode = Everywhere) is expected to return a Map with definition of the action link. It can be either Deep deep link or Context context link. See the code sample below.
if If the logic fails with an exception:
the jump The exception from the logic is displayed as an error notification.
Redirection to another page will not happen.
and the The frontend can display an error , which was set via withFailureMessage(). This message will override the exception message returned from the logic.
In the logic you can use yellowAlert(), redAlert(), or criticalAlert() to display notifications.
criticalAlert() will cancel redirection to another page.
Code Samples
Example of BackEndAction Logiclogic:
Code Block | ||
---|---|---|
| ||
def products = api.inputMatrix('productsDataSet', 'sku') return [ targetPage : AppPages.QC_NEW_QUOTE, targetPageState: [ targetPageItems: products.collect { it -> return it.sku }, targetPageTab: 'items' ] |
Example of a logic which built to build the Result Matrix , which creates the action button , which called calling the BackEndAction Logiclogic:
Code Block | ||
---|---|---|
| ||
def products= api.find("P", 0, 10, null, ["sku", "label", "currency"]) def resultMatrix = api.newMatrix().withColumnFormats([ "sku" : FieldFormatType.TEXT, "label":FieldFormatType.TEXT, "currency": FieldFormatType.TEXT ]).withRows(products); resultMatrix.rowSelectionBackEndAction("productsDataSet") .withLogicName("BackEndActionLogic") .withColumns("sku") .withButtonLabel("New Quote") return resultMatrix |
Example of result matrix with multiple buttons, error handling and passing additional parameters.
...
Result matrix:
Code Block | ||
---|---|---|
| ||
def products = api.find("P", 0, 10, null, ["sku", "label", "currency"])
def resultMatrix = api.newMatrix().withColumnFormats([
"sku" : FieldFormatType.TEXT,
"label" : FieldFormatType.TEXT
]).withRows(products);
resultMatrix.rowSelectionBackEndAction("selectedProducts")
.withLogicName("BackEndActionLogic_Example2")
.withColumns("sku")
.withButtonLabel("New Quote")
resultMatrix.rowSelectionBackEndAction("selectedProducts")
.withLogicName("BackEndActionLogic_Example2")
.withColumns("sku")
.withButtonLabel("New Quote With Header Type")
.withButtonTooltip('Create a quote with the "Embedded_CFO" type')
.withFailureMessage('Error message displayed if the logic throws an exception')
.withSuccessMessage('Success message')
.addFormulaInput('quoteType', 'Embedded_CFO')
.addFormulaInput('quoteLabel', "New Embedded_CFO quote!")
return resultMatrix; |
Code of BackEndActionLogic_Example2:
Code Block | ||
---|---|---|
| ||
// Selected rows in result matrixdef items = api.inputMatrix('selectedProducts', 'sku')
// Quote type passed in .addFormulaInput('quoteType', 'Embedded_CFO')def quoteType = api.input('quoteType')
// Quote label passed in .addFormulaInput('quoteLabel', "New Embedded_CFO quote")def quoteLabel = api.input('quoteLabel')
if (quoteType) {
return [
targetPage : AppPages.QC_NEW_QUOTE,
targetPageState: [
targetPageFields: [
label: quoteLabel,
expiryDate: "2023-12-24" ],
targetPageEntityType: quoteType,
targetPageItemsInputs: items,
targetPageTab: 'items' ]
]
} else {
[
targetPage : AppPages.QC_NEW_QUOTE,
targetPageState: [
targetPageItemsInputs: items,
targetPageTab: 'items' ]
]
} |