Dear developers,
I have aksed my question in support channel for JIRA Software, but I got information that that channel is not for development question and that I should ask here.
We are using Jira Scripting Suite with Jython for some Workflow actions, conditions and valitors and ScriptRunner with Groovy for Scripted fields. In these scripts we read values from custom fields. We have upgraded from Jira 6.4 to Jira 7.0, 7.1, 7.2 and finaly to 7.3.2. Now we are testing every function and we have found some problem with custom fields. Our scripts use method getCustomFieldObjectsByName() to get custom fields, but in Jira 7.3.2 for some reasons this method returns empty collection.
I have analyzed the problem and found something strange. I am not sure if this is new functionality or bug.
JIRA API for version 7.3.2 describes method CustomFieldManager.getCustomFieldObjectsByName(). As a parameter this method takes custom field name and return collection of custom field objects.
It would be great, if some could verify following example.
I am using following Jython code and runnig it from Jython runner. It should be simple to write similar Groovy or Java code. Set the custom field ID, then the code tries to get the custom field using the untranslated name of the field and then it tries to get the custom field object by name using translated names.
from com.atlassian.jira.component import ComponentAccessor
from java.util import Locale
cm = ComponentAccessor()
cfm = cm.getCustomFieldManager()
tm = cm.getTranslationManager()
for cfid in [12459]:
cf = cfm.getCustomFieldObject(cfid)
if cf:
un = cf.getUntranslatedName()
print "CustomField %s:" % (un)
cfn = cfm.getCustomFieldObjectsByName(un)
print " search with name '%s': %s" % (un,cfn)
print " current translation: %s" % (tm.getCustomFieldNameTranslation(cf))
for l in tm.getInstalledLocales():
ll=l.split("_",2)
trn=tm.getCustomFieldNameTranslation(cf,Locale(ll[0],ll[1]))
if trn:
print " %s: %s" % (l,trn)
cfn = cfm.getCustomFieldObjectsByName(trn)
print " search with name '%s': %s" % (trn,cfn)
else:
print "CustomField with ID %s not found" % cfidThis is example to demonstrate probably bug some in Jira code.
(1) Set your profile to en_US. Create custom field cf1. Now customFieldManager.getCustomFieldObjectsByName("cf1") returns collection with this custom field object.
(2) Now, create translation "cf1 en-us" in en_US language for this field and then rename field from "cf1" to "cf1rename1".
Result 2: Now field name is "cf1rename1" but customFieldManager.getCustomFieldObjectsByName("cf1rename1") returns empty colletion. You have to use customFieldManager.getCustomFieldObjectsByName("cf1 en-us") (translated name) to get collection with this custom field.
(3) Now, create translation "cf1 en-uk" in en_UK language for the field "cf1rename1" and then rename this field to "cf1rename2".
Result 3: You cannot find CF using name "cf1rename2" (new name), nor "cf1rename1" (does not exist anymore). You have to use en_US localized name of this field "cf1 en-us".
(4) Set your profile to en_UK. Now rename the field "cf1rename2" to "cf1rename3".
Result 4: You cannot find CF using name "cf1rename2" (does not exist anymore), nor "cf1rename3" (new name). But now, you cannot use either en_US localized name of this field "cf1 en-us" anymore! You have to search this CF using en_UK localized name "cf1 en-uk" now!
I want test this issue on 7.2, 7.1 and 7.0 tomorrow.
Could someone test this issue on his installation and confirm it or disprove it and explain, why this function uses translated names.
Thank you very much.
Regards,
Robert Wolf.