Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Show issue link type options based on the value of a custom field

Hi all,

 

Our users would want to have this set up: when the value "Cognizant Team" in the custom field "Assigned Team" is selected, the system field "Link Issue" will only show the value "is blocked by" and so on.

 

I think this should be feasible with Behaviours of Scriptrunner, as we already had a similar behaviour, but that was for 2 custom fields. I'm not sure how the script should be when 1 field is system field. Here is what I got so far:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.CustomFieldManager;

def mappingList = [
'None': [
'None'
],
'Cognizant Team': [
'is blocked by'
],
'Migration Leads': [
'relates to'
]
]
def assignedteamMappingList = mappingList.keySet() as List

def assignedteamCF = getFieldByName("Assigned Team")
def assignedteamValue = assignedteamCF.getValue()

def linktypeSF = getFieldById("issuelinks-linktype")
def linktypeValue = linktypeSF.getValue()
def listOptions = mappingList.get(assignedteamValue)


def optionsManager = ComponentAccessor.getOptionsManager()
def assignedteamCustomField = customFieldManager.getCustomFieldObjectsByName("Assigned Team")[0]
def assignedteamFieldConfig = assignedteamCustomField.getRelevantConfig(issueContext)
def assignedteamOptions = optionsManager.getOptions(assignedteamFieldConfig)

def assignedteamOptionsMap
if (assignedteamMappingList != []){
assignedteamOptionsMap = assignedteamOptions.findAll {
it.value in assignedteamMappingList
}.collectEntries {
[(it.optionId.toString()) : it.value]
}
assignedteamCF.setFieldOptions(assignedteamOptionsMap)
}

 

Appreciate all the help.

 

Thank you,

Duong

1 answer

Hi @JMP Support

To answer your question, if you intend to filter an Issue Link Type, you must do it using the Behaviour Initialiser. A sample code has already been provided earlier in this community discussion. The Issue Link Type cannot be filtered using the Server-Side Behaviour.

In your requirement, since you intend to update the Issue Link Type option based on the value selected from another list, this will require a Server-Side Behaviour for the specific list and will not work as expected.

I hope this helps to answer your question. :)

Thank you and Kind Regards,
Ram

Hi @Ram Kumar Aravindakshan _Adaptavist_ ,

 

Thank you for your answer.

Do you mean that there's no solution for this requirement? Since you said "this will require a Server-Side Behaviour for the specific list and will not work as expected."

 

Best,

Duong

Hi @JMP Support

I have already answered your question in my previous comment i.e. 

 The Issue Link Type cannot be filtered using the Server-Side Behaviour

In other words, you can only use the Initialiser to filter the Issue Link Type.

You are trying to filter the Issue Link Type based on the value selected from the custom field, i.e. List.  To trigger a behaviour based on the value of a custom field, you will need the Server Side Behaviour, which will not work for the Issue Linke Type.

The alternative I can suggest is to try and filter the Issue Link Type based on the value of a System Field, for example, User's Role, User's Group or maybe the Issue Type using the Initiliser.

You can refer to this Adaptavist Document to see how a filter a system field.

In your case, instead of filtering the Issue Type, you need to filter the Issue Link Type. Please visit this community post for more information, as mentioned in my previous comment.

 

I hope this clarifies your doubt.

Thank you and Kind Regards,

Ram

Like Vikrant Yadav likes this

Hi @JMP Support

 

Is your question answered?

If so, please accept the answer provided.

 

Thank you and Kind Regards,

Ram

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you