Maximo Open Forum

 View Only

 How to Handle long description data when sending to external system via JSON mapping ?

Jump to Best Answer
  • Integrations
Ajay Kotapati's profile image
Ajay Kotapati posted 09-08-2022 10:33
We have integrated Maximo and ServiceNow and while sending WorkLog comments to the servicenow Maximo is sending long description data in the below format.

{
"description_longdescription": "<div style=\"color: rgb(128, 128, 128);\">Maximo Comment.<\/div><div style=\"color: rgb(128, 128, 128);\">Maximo Test\u00a0<\/div><div style=\"color: rgb(128, 128, 128);\">Sending Data to Service Now.\u00a0<\/div><!-- RICH TEXT -->",
"snnumber": "LOE0010205",
"wonum": "9127951",
"workorderid": 9243256
}

How  to remove all HTML tags from the data when sending it to external system ?

Thanks,
 Ajay
Steven Shull's profile image
Steven Shull Best Answer
Unfortunately, there's not a supported way to do this. It's something that has been requested before (https://ibm-ai-apps.ideas.ibm.com/ideas/MASM-I-480) but isn't currently planned.

You can create an outbound processing automation script on the object structure and override the value being sent to the ServiceNow. We have some documentation on overriding the value (not specifically removing rich text) here: https://ibm-maximo-dev.github.io/maximo-autoscript-documentation/integration/osevents

While we wouldn't officially support it, a good starting point might be importing our psdi.util HTML class and utilizing our toPlainText function. At the bottom is a simple test I did on an Asset object structure.

Initially, my text looked like:
            "description_longdescription": "<div>Testing a <b>formatted </b>long <i>description</i>.</div><div> </div><div> <img alt=\"OS use cases\" src=\"https://ibm-maximo-dev.github.io/maximo-autoscript-documentation/static/118396c43cdc8f7f1253072225cf54ae/2c0ba/osusecase.jpg\" /></div><!-- RICH TEXT -->",


With the script it returns:

            "description_longdescription": "Testing a *formatted *long /description/.\n \n OS use cases <https://ibm-maximo-dev.github.io/maximo-autoscript-documentation/static/118396c43cdc8f7f1253072225cf54ae/2c0ba/osusecase.jpg>\n",

It's not a perfect replacement but it's hard to do a perfect replace of HTML text. 

from psdi.util import HTML
def overrideValues(ctx):
    if ctx.getMboName()=="ASSET":
        ctx.overrideCol("DESCRIPTION_LONGDESCRIPTION",HTML.toPlainText(ctx.getMbo().getString("DESCRIPTION_LONGDESCRIPTION")))​
Ajay Kotapati's profile image
Ajay Kotapati
Thank you Steven for this script and it almost fixed our issue.