Greg,
That's the approach I used that worked. For everyone's reference, here's a simple working script, thanks mostly to Andrzej Wieclaw (on the IBM Tech Xchange forum). The publish channel name would be "TESTPUB" in this example.
var MXLoggerFactory = Java.type("psdi.util.logging.MXLoggerFactory");
var logger = MXLoggerFactory.getLogger(
"maximo.script.PUBLISH.TESTPUB.USEREXIT.OUT.BEFORE"
);
function log(msg) {
try {
service.log_error("### JS WRAPPER TEST: " + msg);
} catch (e) {
// last resort
logger.error("JS WRAPPER TEST: " + msg);
}
}
log("Script entered");
// Import classes
var OslcJSONStructureData =
Java.type("com.ibm.tivoli.maximo.oslc.provider.OslcJSONStructureData");
var JSONObject = Java.type("com.ibm.json.java.JSONObject");
var JSONArray = Java.type("com.ibm.json.java.JSONArray");
try {
// Log what irData gives us
var originalJson = irData.getCurrentJSONData();
log("irData.getCurrentJSONData() class = " + originalJson.getClass().getName());
log("Original payload = " + originalJson.serialize());
// Build wrapper JSON
var erDataJson = new JSONObject();
var targetsJsonString = JSON.stringify([
{
method: "POST",
headers: [
{
headerKey: "x-api-key",
headerValue: "0d***59"
}
],
url: "https://example.test/endpoint"
}
]);
var targetsArray = JSONArray.parse(targetsJsonString);
erDataJson.put("targets", targetsArray);
erDataJson.put("payload", originalJson);
log("Wrapped JSON = " + erDataJson.serialize());
// Replace erData
erData = new OslcJSONStructureData(
erDataJson,
osName,
irData.getObjectPath(),
userInfo,
messageType,
false
);
log("erData replaced successfully");
} catch (e) {
log("ERROR in JS wrapper: " + e);
throw e;
}
log("Script exiting normally");
Original Message:
Sent: 1/5/2026 12:44:00 PM
From: Greg Tsarev
Subject: RE: Wrapping a MIF outbound JSON message
Hi Theo, have you tried the following:
In your PUBLISH.<Publish_Channel_Name>.USEREXIT.OUT.AFTER script, parse the message like so:
erJson = JSON.parse(erData.toString())
Then grab the system property and modify the JSON as you need:
erJson.put("targets", ...)
And then set erData to the modified JSON:
erData = StructureData(erJson.toString())
You will need to import some libraries for this to work:
from com.ibm.json.java import JSON
from psdi.iface.mic import StructureData
Please try it and let me know how it goes.
------------------------------
Greg Tsarev
MRM-EAM Consulting Inc.
------------------------------
Original Message:
Sent: 01-04-2026 10:54
From: Greg Tsarev
Subject: Wrapping a MIF outbound JSON message
I've used an HTTP Handler Exit script to modify the end point URL and headers using req.addHeader("header", "value") and req.setURL(url). On second thought, to modify the payload itself after it leaves the publish channel, you should use an After External Exit script for your publish channel. Have you seen this thread: https://community.ibm.com/community/user/discussion/how-to-modify-values-in-json-outbound-message-from-maximo ?
I'll try to get you some examples tomorrow.
------------------------------
Greg Tsarev
MRM-EAM Consulting Inc.
Original Message:
Sent: 01-02-2026 15:34
From: Theo Pozzy
Subject: Wrapping a MIF outbound JSON message
Greg,
Thank you for the link to that document. I have created that type of script, but I can't figure out the input and output variables that let me read and update the outbound payload. The "requestDataS" variable doesn't appear to be available. Have you ever seen a working script?
-Theo
Original Message:
Sent: 1/2/2026 8:20:00 AM
From: Greg Tsarev
Subject: RE: Wrapping a MIF outbound JSON message
Hi Theo, you can use a JSON Mapper to construct most of the payload, and then intercept the message at the HTTP Handler exit using an HTTP Handler Exit script where you can modify the message, the headers and the URL further as you like, including getting the system property and using the value in the message. You can read about it and see some examples here: https://ibm-maximo-dev.github.io/maximo-autoscript-documentation/integration/endpointhandler
Greg
------------------------------
Greg Tsarev
MRM-EAM Consulting Inc.
Original Message:
Sent: 12-30-2025 15:57
From: Theo Pozzy
Subject: Wrapping a MIF outbound JSON message
I have a publish channel that is sending an outbound JSON message to an external system's REST API. I need to take the basic Maximo message and wrap it with some metadata. I want the URL and API key in the message to be replaced with a value coming from Maximo system properties.
What are my options? Can I use the JSON Mapper application? If so, how do you get at the system property values for those fields in the mapping?
Can I do this with an automation script? I looked at the publish channel external exit script, but it looks like they work with a StructuredData object, and I'm not sure how much control I have over the structure of the message.
Any feedback, or better yet, examples, would be very helpful! For reference, this is what I'm trying to get a message to look like:
{
"targets": [
{
"method": "POST",
"headers":[
{
"headerKey": "x-api-key",
"headerValue": "0d************************************************************59"
}
],
"url": "https://externalsys.mydomain.com/updatecue"
}
],
"payload": {
"_action": "Replace",
"_event": true,
"_id": "ABCD-50047",
"_translangcode": "EN",
"description": "CUE description 12:57:32 PM",
"href": "http:\/\/localhost\/maximo\/oslc\/os\/cuestimate\/_T05FT0svNTAwNDc-",
"masterwonum": "2025-1001205730",
"ogslvinitiatedcue": false,
"orgid": "ONEOK",
"plusdestcontrolid": 52119,
"requestnum": "50047",
"requesttype": "JOB",
"requesttype_description": "Job WO",
"siteid": "DISTR",
"status": "APPR",
"status_description": "Approved",
"statusdate": "2025-12-27T16:38:47-06:00"
}
}
-Theo Pozzy
#Integrations
------------------------------
Theo Pozzy
OneGas
------------------------------