Integrate > Case Exchange framework > Case Exchange reference material > Dealing with HTML tags from Service Anywhere

Dealing with HTML tags from Service Anywhere

HPE Service Anywhere uses HTML tags for rich text in the Description, Solution, and Discussion fields of an Incident, for example, <p>, <strong>, <ul>, and so on. By default, Service Manager does not parse these tags, but displays these tags directly. To improve the readability of these fields in Service Manager, the out-of-box integration template (CaseExchangeSM_SAW) uses pre script to handle these tags in the following manner:

Inbound exchange:

  • Automatically removes HTML tags.
  • If the content contains an image and the address of the image does not start with "http://" or "https://", the image is downloaded and stored as an attachment, and the following description is appended:

    And Images are referenced as:
    (1 embedded image(s) <image_name> were downloaded as attachment, please check attachment section)
    

    If the download of an image fails, the following description is appended :

    And Images are referenced as:
    (1 embedded image(s) <image_name> were downloaded failed)
    
  • If the content contains an image and the address of the image starts with "http://" or "https://", the image is not downloaded and the following description is appended:

    And Images are referenced as:
    (Images http://<domain_name_or_IP_address>/<image_name> are from internet)
    

Outbound exchange:

If the content of a field is modified in Service Manager, then all the text in this field will be appended after the original content in Service Anywhere as follows:

This is the original text in Service Anywhere.
#####SM START#####
This is the modified text in Service Manager.
#####SM END#####

The following example illustrates how this mechanism works in each Case Exchange transfer:

  1. The Description field of an Incident has the following content in Service Anywhere.

  2. After the Incident is exchanged, the Description field has the following content in Service Manager.

    And you can find the image in the Attachments section.

  3. You modify this field in Service Manager as follows.

  4. After your update is exchanged to Service Anywhere, the Description field in Service Anywhere contains the following information.

If you want to remove or modify this mechanism from the out-of-box integration template, remove or modify the following code in pre script:

//remove html tags from SAW
    if(ep['properties.Description']) ep['properties.Description'] = lib.CaseExchange_SAWUtil.processHtmlText(param, context, 'description', ep['properties.Description']);
    if(ep['properties.Solution']) ep['properties.Solution'] = lib.CaseExchange_SAWUtil.processHtmlText(param, context, 'solution', ep['properties.Solution']);
    if (ep['Comments'] && ep['Comments'].length > 0) {
        for (var i = 0; i < ep['Comments'].length; i++) {
            ep['Comments'][i]['Body'] = lib.CaseExchange_SAWUtil.processHtmlText(param, context, 'comment', ep['Comments'][i]['Body']);
        }
    }
//process the value which will be posted to SAW rich text field 
    if(sm['action'] && sm['action'] !== "") {
        if(sm['oldvalues']['action']) sm['action'] = lib.CaseExchange_SAWUtil.processOutboundText(context, 'description', sm['action']);
        if(sm['oldvalues']['action'] === undefined) sm['action'] = null;
    }
    if(sm['resolution'] && sm['resolution'] !== "") {
        if(sm['oldvalues']['resolution']) sm['resolution'] = lib.CaseExchange_SAWUtil.processOutboundText(context, 'solution', sm['resolution']);
        if(sm['oldvalues']['resolution'] === undefined) sm['resolution'] = null;
    }