Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to return unchanged SUMMARY in a calculated script?

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













0 votes



One answer

Permanent link

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.



0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,926
× 152
× 42

Question asked: Oct 27 '17, 5:59 a.m.

Question was seen: 2,563 times

Last updated: Oct 27 '17, 6:15 a.m.

Confirmation Cancel Confirm