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

prakashmurugesan July 17, 2017

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

0 votes
Aidan Derossett [Adaptavist]
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.
July 17, 2017

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

 

prakashmurugesan July 17, 2017

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);
}
}
}

Aidan Derossett [Adaptavist]
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.
July 25, 2017

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
TAGS
AUG Leaders

Atlassian Community Events