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

JMP Support December 7, 2021

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

1 vote
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 7, 2021

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

JMP Support December 8, 2021

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

Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 9, 2021

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
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 9, 2022

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