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"So i tried to do:
->
"New Tile with double space"
var html= workItem.getValue(WorkItemAttributes.SUMMARY);Then I tried to do:
var txt = document.createElement("textarea");
txt.innerHTML = html;
return txt.value;
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
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
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.