It's all about the answers!

Ask a question

How to return unchanged SUMMARY in a calculated script?


Guido Schneider (3.4k1486115) | asked Oct 27 '17, 5:59 a.m.

Hello,

I know there are similar questions available on the forum but non was really helping me.

I have a calculated script which handles the Summary, a mediumHTML attribute for a single Work Item Type. Unfortunately the script is also run on all other Work item Types. So For all others I have to return the unchanged Summary.

The problem is, the return value into the summary field is not handled correctly and HTML encoding is happening if I just return the value I get for Summary.

I reduced the whole script to more or less following line:

return workItem.getValue(WorkItemAttributes.SUMMARY);
So this implies, the Summary should not be changed, because the actual value is returned.
But in fact, there is happening an encoding when I save the work item.

For example Summary:
"New  Title with double space"
->
"New  Tile with double space"
So i tried to do:
var html= workItem.getValue(WorkItemAttributes.SUMMARY);
var txt = document.createElement("textarea");
txt.innerHTML = html;
return txt.value;
Then I tried to do:
throw "Known trap";
The good thing, SUMMARY is not changed at all, what I wanted to reach. But it  throws an exception either "document" not known or with my throw message "Know trap". Both fills my logs. So this does also not help.

My primary question is:
- How can I return the SUMMARY without any change out of a calculated script, without throw an exception?
- If only possible with a throw, how can I throw just an Info or something I can filter out in log4j.properties?

Btw. I read the article, calculated scripts are for text fields. But somebody at IBM had the idea to have Summary as mediumHTML, built in and calculated scrips are executed on all Work Item types for built in attributes.
So it does not help me, to tell me this is not supported. I need a solution. And it must be in JavaScripts in WerbUI, because I have dependency fields, so it is not executed server side as much as I know.

regards
Guido













One answer



permanent link
Ralph Schoon (63.1k33646) | answered Oct 27 '17, 6:15 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Guido, I have no answer for you here. I am not able to avoid the encoding of the HTML in JavaScript either.
You might have a chance in Java, but i am not completely sure about that.

If you look at the JavaAPI and its usage you realize that the content for HTML attributes is calculated using

  • XMLString.createFromPlainText
  • XMLString.createFromXMLText
The first one encodes XML/HTML tags so you see them, the second does not do that and they then work.
I think that the JavaScript API basically uses createFromPlainText() on the data you pass and that you are therefore doomed. If you want to be really sure, you would have to raise a PMR.

In the JavaAPI you can control this a lot better.
https://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/ shows how you can use Java instead of JavaScript. You could try to use the correct encoding method and pass the value back.



Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.