cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Rich text in ESI to SAP

gscorpil-2
10-Marble

Rich text in ESI to SAP

Does anyone use rich text on the change notice with ESI sending to SAP?  If so how do you handle the html tags that windchill adds to your description?

8 REPLIES 8

Hi,

ESI Tibco will not translate any thing. if windchill response file sending html tags, you can pass to SAP as is..

 

regards

GAIN Sreeni

We are using PI/PO and are being told it can not process the html tags.  Are you saying sap can handle the html tags?

Hi

I don't have any idea about SAP PI/PO, but what i'm trying say, if you using ESI then it will work.

if possible share ESI response file if your using ESI services and generation XML file..

 

#gainsreeni

<Description>&lt;ul&gt;&lt;li&gt;This is a &lt;strong&gt;test&lt;/strong&gt; of the &lt;em&gt;new &lt;/em&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;rich &lt;/span&gt;&lt;u&gt;text &lt;/u&gt;&lt;s&gt;feature &lt;/s&gt;it &lt;sub&gt;includes &lt;/sub&gt;as &lt;sup&gt;many &lt;/sup&gt;special characters as possible&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(231,76,60);&quot;&gt;test &lt;/span&gt;&lt;span style=&quot;background-color: rgb(46,204,113);&quot;&gt;line &lt;/span&gt;2&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: center;&quot;&gt;Center&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: right;&quot;&gt;Right&lt;/div&gt;</Description>

 

Is an example of what is being sent.  

Expected out put is:

This is a test of the new rich text feature it includes as many special characters as possible
test line 2
Center

Right

Thanks,

 

Response data is fine..

issue with your PI/PO only.. look at it..

it is working for my customer ABBOTT with ESI Tibco and SAP only..

 

regards

#gainsreeni

Thanks for the insights and help!!

BenPerry
15-Moonstone
(To:gscorpil-2)

@gscorpil-2,

I know this is an old post, but https://www.ptc.com/en/support/article/CS312182 addresses this topic partially.

 

Per the SPR, I am told that R&D does not suggest that the extra HTML characters are removed as the downstream system(s) that would receive this information could potentially consume this formatted data.

 

There are two ways this can be solved:

  1. Add some code in an Expression Robot in the workflow template right before the Change Notice hits the Set State Released robot.  The code is pasted below, but the idea is that it copies the plain text version of the rich text description into the original "description" attribute, which is likely not being used in your create/edit/view layouts anymore.  However, at least the plain text description will be stored in the database and shown in the OOTB "description" tag in the ESI output file.  (This is the method I chose.)
  2. Extend ESIECNHeaderRenderer and override adjustElement().  The same java code will be needed: cn.getLongDescription().getPlainText().  In this case you don't need to rely on the code running in the workflow and making a copy of the description (in plain text) in the database.  However, it is a customization and needs to be addressed as such.  (I don't have details since I didn't choose this.)

 

Here is the code for copying the rich text description into the plain text attribute.  As mentioned, this can be dropped into an Execute Expression robot right before the Set State Released node in the Change Notice workflow.  (println statements are just for debugging - you can remove them)

 

if (primaryBusinessObject instanceof wt.change2.WTChangeOrder2) {
    wt.change2.WTChangeOrder2 cn  = (wt.change2.WTChangeOrder2)primaryBusinessObject;
    
    String plainTextDescription = cn.getLongDescription().getPlainText();
    System.out.println("The long decription formatted to plain text is: " + plainTextDescription);
    com.ptc.core.lwc.server.PersistableAdapter obj = new com.ptc.core.lwc.server.PersistableAdapter(cn, null, null, null);
    obj.load("description");
    
    if (plainTextDescription != null) {
        obj.set("description", plainTextDescription);
        obj.apply();
        System.out.println("applied");
        wt.fc.PersistenceHelper.manager.modify(cn);
        System.out.println("saved (modified)");
    } else {
        System.out.println("plainTextDescription was null");
    }
}

 

JasonH
5-Regular Member
(To:BenPerry)

@BenPerry,
This is great, I took it a step further using regex to apply limited formatting so a multi-line description comes out in plaintext as multi-line

JH_9196744_0-1700079229069.png

JH_9196744_1-1700079243787.png

 

 

 

 

if (primaryBusinessObject instanceof wt.change2.WTChangeOrder2) {
    wt.change2.WTChangeOrder2 cn  = (wt.change2.WTChangeOrder2)primaryBusinessObject;
    
    String htmlString = cn.getLongDescription().getFormattedText();
    System.out.println("The long decription is: " + htmlString);
    String plainTextDescription = htmlString
        .replaceAll("(?i)<li[^>]*>", "\n- ") // Add a dash and a space before list items
        .replaceAll("(?i)<tr[^>]*>|<td[^>]*>(?!&nbsp;)", "\n") // Newline before table rows and non-empty table data
        .replaceAll("(?i)<p[^>]*>", "\n") // Insert newline before each paragraph tag
        .replaceAll("<[^>]+>", "") // Remove all HTML tags
        .replaceAll("&nbsp;", " ") // Replace HTML non-breaking spaces
        .replaceAll("\n+", "\n").trim(); // Remove multiple newlines and trim whitespace
    System.out.println("The long decription formatted to plain text is: " + plainTextDescription);
    com.ptc.core.lwc.server.PersistableAdapter obj = new com.ptc.core.lwc.server.PersistableAdapter(cn, null, null, null);
    obj.load("description");
    
    if (plainTextDescription != null) {
        obj.set("description", plainTextDescription);
        obj.apply();
        System.out.println("applied");
        wt.fc.PersistenceHelper.manager.modify(cn);
        System.out.println("saved (modified)");
    } else {
        System.out.println("plainTextDescription was null");
    }
}

 

 

 

Announcements

Top Tags