My scripted fields render wrong, with strange symbols

Deleted user June 8, 2016

I have some groovy files inside a JIRA plugin developed by our team. I install that plugin into JIRA and make scripted fields pointing to that groovy files, using the ScriptRunner plugin. Everythink works fine except for the fields rendering. If I view those fields on a view issue screen, and I refresh it with F5, sometimes the fields render wrong, being Spanish characters as ñ, á, é, í, ó, ú, rendered as question marks. I know that it is a character encoding problem.

The only thing I don't understand is that ON SUCCESSIVE SCREEN REFRESHINGS WITH F5 SOMETIMES THE FIELDS RENDER WELL AND SOMETIMES WRONG. Why the hell is this happeing? Really the browser must be kidding me. Does the character encoding change in successive screen refreshes? What kind of joke is this? Shouldn't the same character encoding be used always? Really I think it has no sense at all that the character encoding changes by pushing F5. I see it as a nasty joke. What do you think?

3 answers

1 accepted

0 votes
Answer accepted
Mahesh S
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 8, 2016

Please add this piece of code on the top of your script (below the import section) and try. It might be a browser cache issue.

enableCache = {-> false}
Deleted user June 8, 2016

Thank you. I will try it. Nevertheless, when I was testing the scripted fields, I am very sure that the browser cache was disabled. I always do that, it is an habit of mine.

Mahesh S
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 8, 2016

True! But there will be cache from the server end as well.

Deleted user June 8, 2016

No it doesn't work. I am experiencing the same issue. In addition, when I am on the scripted fields management section there is a preview button to see how would the field render for a certain JIRA issue, and it always shows well. It is a problem that only shows on the view issue screen.

Really I can't understand anything. This has no sense. At all. No sense. What a hell.

Mahesh S
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 8, 2016

A few questions please.

  • Does this happens for all your scripted fields?
  • What is the type of output (like html,..) of your scripted field?
  • Can you please share the skeleton of your code with dummy values?
Deleted user June 8, 2016

It happens for all scripted fields.

They are of type text.

The code of an scripted field:

import java.text.DateFormat
import java.text.SimpleDateFormat
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor
def dateFormat = new SimpleDateFormat("dd/MM/yyyy") as DateFormat
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def closeCustomField = customFieldManager.getCustomFieldObjectByName("Fecha y hora de cierre")
def closeValue
if (closeCustomField == null) {
closeValue = null;
}
else {
closeValue = issue.getCustomFieldValue(closeCustomField) as Date
}
if (closeValue) {
dateFormat.format(closeValue)
}
else {
"no ha sido cerrada aún"
}

Nearly at the bottom, when it says a phrase in Spanish with the character ú, is where the problem happens.

Deleted user June 8, 2016

Also I have a cache problem as you said, because I am trying to make changes on the fields and I am unable to get those changes reflected on the view Issue screen although I disabled cache on the groovy files by putting your code below the imports.

Mahesh S
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 8, 2016

Are trying to set the value "no ha sido cerrada aún" to closeValue? I don't understand your last else loop. Please explain what you are trying out.

Deleted user June 8, 2016

If the custom field that retains the closing date of the issue has no value, then I return an String for noticing the user.

0 votes
Deleted user June 8, 2016

I don't know how to say this but I restarted JIRA and I am utterly unable to reproduce the problem. It never happens now. It seems that simply JIRA gone crazy, which is not a new thing...

Something that really grinds my gears is that when developing for JIRA it is very frequent that I have lots of troubles that later disappear magically with a restart or something like that, in a way that I never know what is the cause, or if I done something wrong.

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 8, 2016

No need to be quite so dramatic about it. UTF8 wasn't invented just to screw over Mikel Rodriguez.

What template is being used for the field, can you attach a screen cap of the script field config?

Can you make a simple script field with the script:

"ñ, á, é, í, ó, ú"

and see how that renders?

 

 

Deleted user June 8, 2016

XD XD well at least I had some laughs. You have read my mind. Character encodings have screwed over me since the beginning of times... It is a problem of which I have always been unable to get rid of.

I don't know how to say this but I restarted JIRA and I am utterly unable to reproduce the problem. It never happens now. It seems that simply JIRA gone crazy, which is not a new thing...

Something that really grinds my gears is that when developing for JIRA it is very frequent that I have lots of troubles that later disappear magically with a restart or something like that, in a way that I never know what is the cause, or if I done something wrong.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events