getCustomFieldObjectsByName() in Jira 7.3.2 uses translated name instead untranslated name

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" % cfid

This 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.

5 answers

We experience same behaviour on our 7.2.2 server and this is causing a lot of problems and extra work for us. Has to be a bug! Can you confirm that this problem exists for all 7-releases?

Hello,

We experience same behaviour on our 7.2.2 server and this is causing a lot of problems and extra work for us.

I have made a workaround in one of my scripts: get all CFs and then check the untranslated name, but this is stupid workaround and I don't want to change all my scripts this way, because this is really a bug. Nice to hear that someone else has found this problem too. But not nice to hear causing you the problems:-( Fortunately, we have found this problem during upgrade-testing and not after upgrade.

We have made snapshots during upgrade from JIRA 6.4.10, so I could test this issue on JIRA 7.0.11, 7.1.10, 7.2.7 and 7.3.2. On JIRA 7.0.11 and 7.1.10 works this method correctly as on 6.4.10 and I can find CF using field name and not localized name.

On JIRA 7.2.7 is the bug already present. And on 7.3.2 is still present. Now is 7.3.3 out, I have not tested this bug on this newest Jira.

I have opened support request GHS-74788 (I am not sure if you can see it). The Atlassian has answered me:

 

Andy Nguyen 10/Mar/17 12:24 PM

Hi Robert,

You're right in this case. According to your detailed comment (with steps to reproduce) this does sound like a bug. However, can you please provide us with the ready-to-run code snippet and suggest where/how we can run to test it on our side? We will then proceed with the bug verification and get back to you with the results.

We hereby would like to thank you for the report and apologize for any inconvenience caused. Look forward to hearing from you.

Kind regards,

Andy

 

 

Andy Nguyen 16/Mar/17 3:36 PM

Hi Robert,

Good day and sorry for keeping you waiting.

Honestly we haven't been able to prioritize this issue in the last few days. It does sound like a bug to us, however, just to set the right expectation, even in case it's verified to be a real bug, there may not be an immediate action taken against it.

We will try to get back to you with further information tomorrow.

Thanks again for your kind understanding,

Andy

 

Currently this support request is in "Atlassian Investigating". I have reported the same steps to reproduce to Atlassian in my support case as here.

Regards,

Robert Wolf.

This bug is still present on JIRA 7.3.3

Next comment from Andy:

Andy Nguyen 17/Mar/17 1:37 PM

Hi Robert,

I've taken some time to play around with this and would agree on 99% of your observations. However, the very slight difference that I discovered seems to suggest that this is not actually a Bug. It may be an intended behavior in an unwanted way. I will write a summary here and send it to a developer to get his opinion of it. We will then raise a Bug/Suggestion ticket or a KB article where applicable.

Will keep you posted,

Andy

 

 

 

Hello Oddvin,

Andy has created an issue https://jira.atlassian.com/browse/JRA-64958 but there is some illogical description for input value if there is name translation. I don't believe it should work this way.

Regards,

Robert Wolf.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,319 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot