Additional Ready-made Activities supported by Request Modeler

Canvas facilitates the purpose of using additional ready-made activities, supported by Request Modeler. For more information on the activities, supported by Request Modeler and their associated instruction classes, refer Activities. For the full set of information on stateModelLibrary.json, refer Library JSON.

Before pre-confirmation screen in Request Modeler, the form data that is sent through the request can be accessed using $context.FORM_ITEM_ID or $context.formmodelkey.

Dynamic values in Request Modeler can be accessed as follows:

  • $response - To get response data set in one activity.
  • $response.serviceResp - To get web service response.
  • $user - To get user related data.


Connecting to a Web Service using existing Data Source ID

The connectToWS activity facilitates the purpose of using the existing data source ID to connect to the web service. The following code snippet is a sample reference to use the connectToWS activity in stateModelLibrary.json:

{      
	"id" : "W01",
	"type" : "connectToWS",
	"datasourceId" : "WS_DS" //existing data source ID
}

Updating the Request Data

The updateDB activity paves the way for updating the request data by specifying the model or request ID and the relevant fields that require appropriate updates. The following code snippet is a sample reference to use the updateDB activity in stateModelLibrary.json:

The fieldValue can be applied from the context value or you can even use the default or static value.


{
	"id" : "DB01",
	"type" : "updateDB",
	"modelId" :"CARD_REQ", //optional
	"fieldList" :
	[{
		"fieldName" : "CARD_TYPE",
		"fieldValue" : "$response.serviceResp.status",
		"defaultValue" : "Debit"
	},
	{
		"fieldName" : "CARD_NO",
		"fieldValue" : "$context.OLD_CARD_NO"
	}]
}


The model ID can be passed from the client side. If the model ID is passed through JSON and the client side, then the JSON will get the top priority. It is feasible if you pass the model ID either as a JSON parameter or from the client side.

The following JavaScript code is a sample reference on passing the model ID from the client side:

fm.model.setValue("TARGET_MODEL_ID","CARD_REQ")

Sending Responses to the Client

The setClientResponse activity can be used to send a response to the client by giving appropriate keys and relevant values in fieldList. The following code snippet is a sample reference to use the setClientResponse activity in stateModelLibrary.json:

{
	"id" : "RESP01",
	"type" : "setClientResponse",
	"fieldList" :
	{
		 "updatedCardNo" : "$context.OLD_CARD_NO",
		 "serviceStatus" : "$response.serviceResp.status"
	}
}

Raising Events based on Event Configuration

The processEvents activity can be used to raise events based on event configuration in stateModelLibrary.json. The events can also be raised from the existing model data. Events need to be mapped with respective alerts and audits. The following code snippet is a sample reference to use the processEvents activity in stateModelLibrary.json:

Currently, only default values can be used. If no values are assigned, then the model data will be automatically considered as eventData.


{
	"id" : "PE01",
	"type" : "processEvents",
	"eventConfig" :
	{
		"productCode" : "CUSER",
		"subProductCode" : "CUSER",
		"functionCode" : "VIEW",
		"action" : "ADD",
		"eventData" :
		{
			"ADD_KEY" : "ADD_VALUE"
		}
	}
}

The following code snippet is a sample reference to use this activity in stateModelLibrary.json, based on the event configuration from the client side:

{
	"id" : "PE01",
	"type" : "processEvents"
}

The following JavaScript code is a sample reference to set event configuration on the client side:

var eventConfig = 
{
	"productCode" : "CUSER",
	"subProductCode" : "CUSER",
	"functionCode" : "VIEW",
	"action" : "ADD"
}
fm.model.setValue("eventConfig",eventConfig);


You can add a new activity by extending the processEvents activity, which helps to override the data preparation method.

The following code snippet serves as a sample reference:

protected Map prepareDataForEvent(Map eventData,ReqModelActivityContext context,Event event)
{
	//add your code to form event data
}

Supporting Post Publish Activities

The post publish activities can be used to initiate a particular action (such as Submit or Approve), from the server-side hook. Activities like updating the database and publishing requests can be carried out in a feasible manner. Assuming that the Flag introduced is POST_PUBLISH.

  1. While creating a request in Canvas Studio, specify "POST_PUBLISH" : "Y" in Additional Params field, so as to proceed with post publish activities. For the relevant information on creating a request in Canvas Studio, refer Configuring Request Modeler and Creating Library Request. The following code snippet is a sample reference on adding the post publish activities, involving the Submit action in stateModelLibrary.json:

 stateModelLibrary.json is depicted as a sample workflow. You can use your own, customized workflow JSON too.


{
	"id" : "AO",
    "description" : "Ready For Authorization",
    "isDefault" : "false",
    "actions" :
	[{
		"id" : "SUBMIT",
        "description" : "When a pre confirmation is submitted",
        "transactionRequired" : "true",
        "isInEditMode" : false,
        "activityChain" :
		[{
			"id" : "DB01",
			"type" : "updateDB",
			"modelId" :"CARD_REQ",
			"fieldList" :
			[{
				"fieldName" : "CARD_TYPE",
				"fieldValue" : "$response.serviceResp.status"
			},
			{
				"fieldName" : "CARD_NO",
				"fieldValue" : "$context.OLD_CARD_NO"
			}]
		}]
	}]				                  
}