Skip to main contentCarbon Design System

Invoke channel scripting

Like Publish channels, Invoke channels are used for outbound invocation from Maximo. The only difference is that Publish channel is one way (request only) and Invoke Channel is two way (request response). Since there is a request and response, there will be two sets of exits - one set of exits for request and one set for response. The following screen shot shows the wizard:

Invoke Channel Exits

The following table lists the script points for Invoke Channel:

Script PointPurpose
Oubound External ExitThis is for prepping the outbound call. This can be used to prepare the request data or the request URL (as shown in following example)
Outbound Before User ExitSimilar to the outbound external exit, it can be used for preparing the data or the request endpoint data. Use this if there is already an external exit and you want to customize some data before it hits that exit.
Outbound After User ExitSimilar to the outbound external exit, it can be used for preparing the data or the request endpoint data.
Inbound External ExitThis is for handling the response of the invocation, if there is a response. Like any inbound external exit, this should be used to map the response data to Maximo internal format
Inbound Before User ExitSimilar to the inbound external exit, it can be used for mapping the inbound data.
Inbound After User ExitSimilar to the inbound external exit, it can be used for mapping the inbound data.

All the outbound script points have the same variables as defined in publish channel scripting. All inbound script points have the same variables as defined in the Enterprise service scripting document. The use case here is to set the city and state in the Organization Application->Address tab when the zip code is entered. Assume you have the following external REST API:

GET {zip to city uri}?zips={zip code}

The response is a json that returns the city and state for the {zip code}. You want to invoke that API when the user enters the zip code and then tabs out (of attribute Address4). To do this, You would need to create an Object Structure for the Address MBO, named for example, MXADDRESS. You are then going to set-up an invoke channel with an HTTP endpoint that has the URL set to the {zip to city uri}. You are going to set the zips query parameter dynamically in the exit scripts. Make sure that you set the “process response” check box and set the request and response Object Structure to MXADDRESS.

You will then create the external exit scripts for both the request and response handling. You will use the Create Scripts for Integration menu option from the Autoscript application to create the request and response exits for Invoke Channel. For both cases, you are going to choose the “External Exit” option. The following request (INVOKE.ZIPCHANNEL.EXTEXIT.OUT) exit (in py) will look like:

from java.util import HashMap
from psdi.iface.router import HTTPHandler
from psdi.iface.mic import IntegrationContext
from psdi.iface.mic import MetaDataProperties
epProps = HashMap()
urlProps = HashMap()
zip = irData.getCurrentData("ADDRESS4");
urlProps.put("zips",zip)
epProps.put(HTTPHandler.HTTPGET_URLPROPS,urlProps)

The following response (INVOKE.ZIPCHANNEL.EXTEXIT.IN) exit (in js) will look like:

var resp = JSON.parse(erData.getDataAsString());
var irData = new StructureData(messageType, osName, userInfo.getLangCode(), 1, false, true);
irData.setCurrentData("ADDRESS3", resp.zips[0].state);
irData.setCurrentData("ADDRESS2", resp.zips[0].city);

The following response json is assumed to be like this (based on a sample popular rest service out there):

{
"zips":[
{
"state":"Blah",
"city":"Blah1"
….
}
]
}

This script could have been optimized a little bit more for the given use case. For example, you could have directly set the json data to the MBO, something that you can do only in case of Invoke Channels.

IntegrationContext = Java.type("psdi.iface.mic.IntegrationContext");
var resp = JSON.parse(erData.getDataAsString());
var mbo = IntegrationContext.getCurrentContext().getProperty("targetobject");
mbo.setValue("address3",resp.zips[0].state);
mbo.setValue("address2",resp.zips[0].city);
service.raiseSkipTransaction();

You got the MBO from the IntegrationContext “targetobject” property, which stores the reference of the MBO to which you are going to set the json response. Setting the response can be done by MIF using the irData. In the following example, you will see how you can do it without needing to create the irData. You use the resp json object to get the state and city and set it directly to the “mbo”. Then you can just skip the rest of MIF processing by asking the service object to skip the transaction. You can use this in other forms of inbound exits - like the user exit and the external exit for Enterprise services. Make sure that you set the data yourself to the MBOs that you want and the skip the rest of MIF processing. Also, this IntegrationContext “targetobject” property is only available for exits in InvokeChannel.

You will write an Attribute LaunchPoint script (action event) for the Address4 attribute (zip code attribute in Address object) to invoke this channel when the zip code value is set.

service.invokeChannel("zipchannel")

You use the service variable to do this call. This will call the channel, which in turn goes through the request and response exits.