Exits for publish channels

You can script three exit points for publish channels. The purpose is mostly for data transformation. You can use the exit to make direct calls to external services and then skip the rest of the publish channel processing.

The following table lists some of the implicit variables that the publish channel scripts have:
Table 1. Implicit variables for publish channel scripts
Variable Purpose
erData An instance of psdi.iface.mic.StructureData that is used to hold the external document. The value of this variable is set to null for external exits and before the user exits in the channel.
irData An instance of psdi.iface.mic.StructureData that is used to hold the internal document.
ifaceType The interface type name.
ifaceName The channel name.
osName The object structure name.
messageType The message type.
extSystem The external system name.
userInfo The UserInfo object that represents the authenticated user who started this service.
conn The JDBC connection object.
The following script is an example that changes the description of operating assets on outbound transactions. In this scenario, the MXASSET object structure provides irData, an instance of psdi.iface.mic.StructureData, to the MXASSET publish channel (MXASSETINTERFACE) for processing. An automation script is configured to run on the external exit class of the publish channel. The script checks the status of the asset in the irData element. If the asset is in an operating status, the script inserts a value in the description field and prints a message to the log file. The erData element is then constructed and is forwarded to the external system. If this action is done as an external exit, the name of the script is PUBLISH.MXASSETINTERFACE.EXTEXIT.OUT.
if irData.getCurrentData("STATUS") == 'OPERATING' :
  irData.setCurrentData("DESCRIPTION","hello")
  service.log("MYASSET description change")
The following example is a user exit before the external exit that sets the descriptions to the irData for the job tasks in a job plan.
jobTasks = irData.getChildrenData("JOBTASK")
numberOfChildren = jobTasks.size()
for i in range(numberOfChildren):
    logger.info("Inside Loop" + str(i))
    jT = jobTasks.get(i)
    irData.setAsCurrent(jT)
    taskPrefix = "This is task number: "
    newDescription = taskPrefix + str(i)
    irData.setCurrentData("DESCRIPTION", newDescription)

This irData API usage is independent of JSON or XML. However, use the irData.setAsCurrent(jT) API so that it works for JSON and XML. If you use the irData.setAsCurrent(jobTasks, i) API instead, it works only for XML and not for JSON.