Skip to main content

Version: 24.10

Invoke

The invoke property allows you to configure a Fluent Function service as a data source or data index value for the Details screen field mappings that are used to display data in key info cards and custom cards. The Fluent Function must return a JSON response that can be used to configure the Workspaces mapping fields.

info

For the configured Fluent Function to work correctly, the response should follow the JM standard API response format. For example:

{
"result": [
{
"customProp": "test",
...
}
]
}
info

The request to the Fluent Function is constructed in the following way. It includes the configuration and the txn 'submissionId' values in an array. This could be single or multiple values.

{
txnId: [123922, 123924]
serviceName: 'DAO - Fluent Function',
versionNumber: {
dataIndex: 'properties["invokeVersion"]',
}
}

Customization attributes supported for the invoke property include serviceName, versionNumber, and params.


invoke: {
serviceName: 'DAO - Fluent Function',
versionNumber: {
dataIndex: 'properties["invokeVersion"]',
},
note

In order to use invoke functions, the user must have the Invoke Fluent Functions permission.

Attributes

All attributes are optional unless otherwise indicated.

AttributeDescription
serviceNamestring
Required. The name of a Fluent Function to be invoked from Journey Manager (JM).
To see a list of available Fluent Functions, login to JM and navigate to Services > All Services.
versionNumberGlobalInvokeVersionNumber
The version of the Fluent Function identified by serviceNameto invoke. If not specified, the latest version is used.
paramsGlobalParams
Additional attributes to send in the request.
rulesGlobalRules
Used as an additional control to show or hide the invoke function in the Workspaces UI.
To learn more about rules, see Visibility Rules.

To view the full list of available attributes, see the API Reference.

Example

This example demonstrates how to configure an invoke property in the process space using an example Fluent Function that returns an object as a data response. The Fluent Function is called DAO - Documents Checklist, and the example uses version 0.1.0 of this Fluent Function.

Here is the Groovy script definition for the DAO - Documents Checklist Fluent Function. Note the object returned by the invoke method.

DAO - Documents Checklist
import com.avoka.tm.func.*
import com.avoka.tm.svc.*
import com.avoka.tm.util.*
import com.avoka.tm.vo.*
import groovy.transform.TypeChecked
import jakarta.servlet.http.*
import groovy.json.JsonSlurper;
import groovy.json.JsonOutput
import groovy.json.JsonGenerator
import com.avoka.tm.query.*


@TypeChecked
class FluentFunction {

// Injected at runtime
public Logger logger

/*
* Perform Fluent Function call.
*
* returns: FuncResult
*/

public class Products {

RequiredDocuments[] products

}

public class RequiredDocuments {

String applicationType
Boolean status
String trust
String superSaver
String standardChecking
Documents[] documents
}

public class Documents {

String name
String required
String available
}

FuncResult invoke(FuncParam param) {

// Example Response Data

String payslips = "No"
String addressProof = "No"
String driversLicense = "No"
String employmentStatus = "No"
String utilityBills = "No"
Boolean checkStatus = true;


List<Txn> txns = new TxnQuery().setJobRefNumber(param.txn.jobRefNumber).withFileAttachList().listValues()

txns.eachWithIndex { item, index ->

if (item.fileAttachList.attachName.toString().toLowerCase().contains("payslip")) {payslips = "Yes"}
if (item.fileAttachList.attachName.toString().toLowerCase().contains("address")) {addressProof = "Yes"}
if (item.fileAttachList.attachName.toString().toLowerCase().contains("license")) {driversLicense = "Yes"}
if (item.fileAttachList.attachName.toString().toLowerCase().contains("employment")) {employmentStatus = "Yes"}
if (item.fileAttachList.attachName.toString().toLowerCase().contains("utility")) {utilityBills = "Yes"}

}

if(payslips.equals("Yes") && addressProof.equals("Yes") && driversLicense.equals("Yes") && employmentStatus.equals("Yes")) { checkStatus = false; }

String allProducts = param.txn.propertyMap.get("AllProducts");

Documents[] docoList = new Documents[5];

docoList[0] = new Documents(name:"Payslips", required: "Yes", available: payslips);
docoList[1] = new Documents(name:"Address Proof", required:"Yes", available: addressProof);
docoList[2] = new Documents(name:"Driver's License", required:"Yes", available: driversLicense);
docoList[3] = new Documents(name:"Employment Letter", required:"Yes", available: employmentStatus);
docoList[4] = new Documents(name:"Utility Bills", required:"No", available: utilityBills);

RequiredDocuments[] reqDocs = new RequiredDocuments[1];

String productTrust = "N/A"
String productSuperSaver = "N/A"
String productStdChecking = "N/A"

if(allProducts != null) {productTrust = allProducts.contains("Trust") ? "Yes" : "No"} else {productTrust= "No"}
if(allProducts != null) {productSuperSaver = allProducts.contains("Super Saver") ? "Yes" : "No"} else {productSuperSaver = "No"}
if(allProducts != null) { productStdChecking = allProducts.contains("Standard Checking") ? "Yes" : "No"}else {productStdChecking = "No"}

reqDocs[0] = new RequiredDocuments(
applicationType: 'Deposit Account',
status: checkStatus,
trust: productTrust,
superSaver: productSuperSaver,
standardChecking: productStdChecking,
documents: docoList)


Products prods

prods = new Products (products: reqDocs);


// Parse the response
FuncResult resultObj = new FuncResult();

resultObj.data.put("result", prods)
return resultObj;
}
}

Now, add the invoke property in the process space configuration.

src/configs/custom/process.ts
import { ConfigCurrentSpace } from '@transact-open-ux/workspaces/dist/types';

export const processConfig = (): ConfigCurrentSpace => ({
...
invoke: {
serviceName: 'DAO - Documents Checklist',
versionNumber: '0.1.0',
},
...
});

export default processConfig;

Finally, you can use various attributes of the Fluent Function response object in a custom card configuration, for example, for the dataSource and for dataIndex values in the properties array.

$docsList: {
label: 'Selected Products',
icon: 'InfoTwoTone',
type: 'tableExtended',
dataSource: 'invoke.products',
hideEmpty: true,
properties: [
{
label: 'Application Type',
dataIndex: 'applicationType',
type: 'text',
},
{
label: 'Status',
dataIndex: 'status',
type: 'alert',
},
{
label: 'Trust',
dataIndex: 'trust',
type: 'text',
},
{
label: 'Super Saver',
dataIndex: 'superSaver',
type: 'text',
},
{
label: 'Standard Checking',
dataIndex: 'standardChecking',
type: 'text',
},
],
sections: [
{
label: 'Required Documents',
type: 'table',
dataSource: 'documents',
properties: [
{
label: 'Name',
dataIndex: 'name',
type: 'text',
},
{
label: 'Required',
dataIndex: 'required',
type: 'text',
},
{
label: 'Available',
dataIndex: 'available',
type: 'text',
},
],
},
],
},

Triggering an invoke on completion of another action

To call an invoke fluent function on the successful completion of another action, you need to use the onSuccess property of the first action's configuration. In the example config code below, the 'DAO - Email Assignment" invoke fluent function will be run on the successful completeion of the Assign and Reassign actions:

actions: {
Assign: {
label: 'Assign',
onSuccess: {
serviceName: 'DAO - Email Assignment',
versionNumber: '0.1.0',
},
},
Unassign: {
label: 'Unassign',
},
Reassign: {
label: 'Reassign',
onSuccess: {
serviceName: 'DAO - Email Assignment',
versionNumber: '0.1.0',
},
},