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