Updating an custom filed in a issue should update the custome filed dropdown values in different IT

i have create a issue(issue type: responsiblity), i need to see this value in one of the custom fileds in another issue type as drop down value. this is working.

 

But when i update the  issue . value of custome field  is not getting updated or when i delete it is not getting removed .

 

Any suggestions?

1 answer

Hey Prakash!

This kind of sounds like a re-indexing issue to me. 

Could you try a re-index and see if that fixes anything for you? If not, I can help you narrow down to what the issue actually is.

But just to make sure that I have everything straight, could you elaborate a little more on what the issue is. Are you using a behaviour to set this custom field upon creating an issue, or something else? What types of values does the custom field consist of?

Additionally, it would be helpful if you could add the script that you are using and some screenshots to help me visualize the issue.

Thanks!

Aidan

 

Hi Aidan,

reindexing didnot fix my issues.

Am using script runner to implement this feature not using behavior.

I have created  a issue type on the name "Responsibility"

upon creatiing an issue with this type it has to update the custom filed named "Responsibilities" . upon creating multiple issues of this issue type it has create to update the custom filed "Responsibilities" as drop down values. this working fine for now

This event is triggered on event issue created.

 

But when i rename the issue which i create of issye type Responsibility or when i delete the issue, it has to update the custom filed "Responsibilties" automaticall but this is not working for now. could yu please help me how to configure this. 

 

Ading script.

 

import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.customfields.option.*
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.config.FieldConfigScheme
import com.atlassian.jira.issue.fields.config.*
import com.atlassian.jira.issue.Issue


def issue = event.issue as Issue
if (issue.issueType.name == "Responsibility"){
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def name = customFieldManager.getCustomFieldObjectByName("Name")
def nameValue = issue.getCustomFieldValue(name) as String

OptionsManager optionsManager = ComponentManager
.getComponentInstanceOfType(OptionsManager.class);

def resField = customFieldManager.getCustomFieldObjectByName("Responsibility")
def responsibilitiesField = customFieldManager.getCustomFieldObjectByName("Responsibilities")
List<FieldConfigScheme> resSchemes = resField.getConfigurationSchemes();
List<FieldConfigScheme> responsibilitiesSchemes = responsibilitiesField.getConfigurationSchemes();
Option newOption = null;

if (resSchemes != null && responsibilitiesSchemes!= null && !resSchemes.isEmpty() && !responsibilitiesSchemes.isEmpty()) {
FieldConfigScheme resSc = resSchemes.get(0);
FieldConfigScheme respoSc = responsibilitiesSchemes.get(0);
Map resConfigs = resSc.getConfigsByConfig();
Map respoConfigs = respoSc.getConfigsByConfig();
if (resConfigs != null && respoConfigs != null && !resConfigs.isEmpty() && !respoConfigs.isEmpty()) {
FieldConfig resConfig = resConfigs.keySet().iterator().next();
FieldConfig respoConfig = respoConfigs.keySet().iterator().next();
Options responsibilities = optionsManager.getOptions(respoConfig);
int numberAdded = 100;
newOption = optionsManager.createOption(resConfig, null,
new Long(numberAdded),
nameValue);
def responsibilitiesOption = optionsManager.createOption(respoConfig, null,
new Long(numberAdded),
nameValue);
}
}
}

Hey again Prakash,

Sorry for my belated reply!

Behaviours is actually a part of ScriptRunner. So I suppose I was more-so asking for you to clarify on which part of ScriptRunner you are usuing. For example, are you working with a script-field, a script listener, some script fragment, etc...

Additionally, You say that the reindexing didn't fix the problem, which I would expect. However, did it update the issues so that they at least temporarily showed the correct values that they are supposed to?

Could you add some screenshots of the problem please?

My hunch is that, althought you are changing the value of the custom field in one issue, that updated value is not being stored in the database and is therefore not being update on the issue that it is linked to.

I could be wrong however. So I'll be going over your script to see if anything else is causing this strange behaviour.

Aidan

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

168 views 0 4
Read article

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