Hello community,
Due to a reported vulnerability in Atlassian, we have upgraded our Jira instance to version 9.12.22 and updated all our add-ons, including ScriptRunner. However, after the upgrade, we noticed the following Behaviour scripts for service management stopped working. Other scripts for Service Management also stopped working due to this issue. I had to turn off the below script for the other script to work. It doesn't show any error, and I am unable to find a fix. Can someone please help? Thanks.
import com.atlassian.jira.config.IssueTypeManager
import com.atlassian.servicedesk.api.requesttype.RequestTypeService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.project.component.ProjectComponent
Map exclusiveComponentByRequestType = [
"Technical Support ": ["Software","Hardware","Accounts"]
]
if (!requestTypeName) {
return
}
def validComponents = issueContext.projectObject.components
if (exclusiveComponentByRequestType.containsKey(requestTypeName)) {
def validComponentNames = exclusiveComponentByRequestType[requestTypeName]
validComponents = validComponents.findAll { it.name in validComponentNames }
} else {
exclusiveComponentByRequestType.each{rtName, componentNames->
if(rtName != requestTypeName){
validComponents.removeAll { it.name in componentNames }
}
}
}
getFieldById("components").setFieldOptions(validComponents)
Jira ve ScriptRunner yükseltmenizden sonra Hizmet Yönetimi (Servis Yönetimi) Davranışı ile karşılaştığınızda karşılaştığınız sorun çözülecektir. Bu tür sorunlar, genellikle Jira veya eklenti güncellemeleriyle ortaya çıkan API değişiklikleri veya hatalardan kaynaklanabilir.
Yaptığım incelemelere göre, sorununuzun olası nedenleri ve çözüm önerileri ayrıntılı olarak detaylandırılmıştır:
ScriptRunner Hatası: Jira 9.12.x'in çalıştırılmasının ardından, özellikle Hizmet Yönetimi portalında setFieldOptions yöntemlerinin bileşenleri (Components) alanı için düzgün çalışmasına neden olan bilinen bir ScriptRunner sistemi mevcuttu.[ 1 ] Bu hata, Adaptavist tarafından ScriptRunner'ın 8.47.0 sürümünde tedavi edilmiştir.[ 2 ]
API kopyalamaları: Kullandığınız Jira sürümü ile birlikte ScriptRunner'ın Groovy API'lerinde değişiklikler olmuş olabilir. Özellikle requestTypeService veya paketlere erişim yöntemlerinde değişiklikler yaşanmış olabilir.
Betiğin Çalışma Zamanlaması (Initializer): Betiğiniz bir "initializer" (başlatıcı) olarak çalışıyorsa ve requestTypeName değişkeni bu aşamada henüz mevcut değil, betik beklendiği gibi çalışabilir.
Sorunun çözümü için aşağıdaki adımları izlemenizi bildirdik:
Öncelikle ScriptRunner eklentinizin kurulumunu kontrol edin. Eğer 8.47.0'dan daha eskiyse lütfen güncel sürüme geçin. Bu güncelleme, setFieldOptions yönteminin bileşenleri alanıyla ilgili bilinen hatalı çözülecektir.[ 2 ]
Mevcut olanınızın daha sağlam ve değişikliklere karşı daha dayanıklı hale getirilmesi için bazılarının daha dayanıklı olması sağlanır. Aşağıda, hata ayrıntıları için log eklenmiş ve olası null değerlerine karşı daha güvenli hale getirilmesi için bir betik versiyonu bulunmaktadır:
com.atlassian.jira.component.ComponentAccessor'ı içe aktarın
com.atlassian.servicedesk.api.requesttype.RequestTypeService'i içe aktarın
org.apache.log4j.Logger'ı
içe aktarın org.apache.log4j.Level
// Hataları düzenlemek için log başlatma
def log = Logger.getLogger("com.onresolve.jira.groovy.JiraServiceManagementBehaviour")
log.setLevel(Level.DEBUG)
// İstek tipi adını güvenli bir şekilde al
def requestTypeNameValue = getRequestTypeName()
log.debug("Mevcut İstek Tipi Adı: ${requestTypeNameValue}")
if (!requestTypeNameValue) {
log.debug("İstek Tipi Adı başarısız, betik sonlandırılıyor.")
return
}
// Bileşenleri barındırmak için
harita Harita exclusiComponentByRequestType = [
"Teknik Destek": ["Yazılım", "Donanım", "Hesaplar"]
]
def bileşenlerField = getFieldById("bileşenler")
if (!componentsField) {
log.error("Bileşenler alanı hata.")
return
}
def project = issueContext.projectObject
if (!project) {
log.error("Proje nesnesi bulunamadı.")
return
}
def allComponents = project.components
log.debug("Projedeki tüm programlar: ${allComponents?.collect { it.name }}")
def validComponents
if (exclusiveComponentByRequestType.containsKey(requestTypeNameValue)) {
def validComponentNames = onlyComponentByRequestType[requestTypeNameValue]
log.debug("Bu istek tipi için geçerli kabul edilen adları: ${validComponentNames}")
validComponents = allComponents.findAll { it.name in validComponentNames }
} else {
def ComponentsToExclude = excluComponentByRequestType.values().flatten() as Set
log.debug("Diğer istek tiplerine özel hizmetler (hariç tutulacaklar): ${componentsToExclude}")
validComponents = allComponents.findAll { !(it.name in ComponentToExclude) }
}
log.debug("Alana atanacak finansal hizmetler: ${validComponents?.collect { it.name }}")
bileşenlerField.setFieldOptions(validComponents)
Bu geliştirilmiş betiğin zamanı:
Hata Ayıklama (Logging): Betiğin hangi adımları çalıştırdığını ve değişkenlerin değerlerini Jira'nın log dosyasından ( atlassian-jira.log ) takip edebilirsiniz. Bu, sorunu çözmeyi bulur.
Daha Güvenli Kod: getRequestTypeName() gibi yöntemlerin açıklamaları ve boş kontrollerini içerir.
Daha Verimli Filtreleme: başka yerlerdeki mantık, diğer istek türlerine ait tüm bileşenler tek seferler hariç tutularak daha verimli çalışır.
Yukarıdaki adımları çözmezse, requestTypeService kullanımıyla ilgili olası bir uyumsuzluk olabilir. Bu durumda, istek tipini doğrudan alan getRequestTypeName() işlevini kullanmak genellikle daha güvenilirdir. Paylaşılan geliştirilmiş betik halihazırda bu yaklaşıyor.
Büyük sorunlara neden olan sorunlar, ScriptRunner'ın eski bir programını kullanmanızdan kaynaklanmaktadır. ScriptRunner'ı en güncel sürüme yükseltme sorunu çözecektir. Sorun devam ederse yukarıda paylaştığım geliştirilmiş ve hata sayıları günlükleri eklenmiş betiği kullanarak sorunun nerede olduğunu tespit edebilir ve çözebilirsiniz.
Hi Kadir,
why don't you translate your comment into english so everybody around the world is able to understand what you try to say?
Best regards, Rolf
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Kadir SELÇUK I translated the script into English. I replaced my script with yours, however, it's not limiting the component to those three mentioned in the code for "Technical Support" request type. Though the other scripts I have for service management started working. But this one suppose to only display those three component for Technical Support request type is still not working. The below is log and translated script. Thanks
Logs
2025-07-11T10:44:12,832 DEBUG [groovy.JiraServiceManagementBehaviour]: Current Request Type Name: Technical Support
2025-07-11T10:44:12,833 DEBUG [groovy.JiraServiceManagementBehaviour]: All components in the project: [Accounts, Analytics, Confluence, Database, Decommission, Hardware, Intranet, Jira, Network, Office, Other, Software, Teams, Website]
2025-07-11T10:44:12,833 DEBUG [groovy.JiraServiceManagementBehaviour]: Allowed component names for this request type: [Software, Hardware, Accounts]
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.servicedesk.api.requesttype.RequestTypeService
import org.apache.log4j.Logger
import org.apache.log4j.Level
// Set up logging for troubleshooting
def log = Logger.getLogger("com.onresolve.jira.groovy.JiraServiceManagementBehaviour")
log.setLevel(Level.DEBUG)
// Get the current request type name
def requestTypeName = getRequestTypeName()
log.debug("Current Request Type Name: ${requestTypeName}")
// Stop the script if the request type name couldn't be retrieved
if (!requestTypeName) {
log.debug("Failed to retrieve request type name, stopping script.")
return
}
// Define allowed components for each specific request type
def allowedComponentsByRequestType = [
"Technical Support": ["Software", "Hardware", "Accounts"]
]
// Get the 'components' field
def componentsField = getFieldById("components")
if (!componentsField) {
log.error("Components field not found.")
return
}
// Get the current project
def project = issueContext.projectObject
if (!project) {
log.error("Project object not found.")
return
}
// Get all components defined in the project
def allComponents = project.components
log.debug("All components in the project: ${allComponents?.collect { it.name }}")
def validComponents
// If the request type has specific allowed components
if (allowedComponentsByRequestType.containsKey(requestTypeName)) {
def allowedNames = allowedComponentsByRequestType[requestTypeName]
log.debug("Allowed component names for this request type: ${allowedNames}")
validComponents = allComponents.findAll { it.name in allowedNames }
} else {
// Exclude components that are assigned to other request types
def excludedNames = allowedComponentsByRequestType.values().flatten() as Set
log.debug("Components to exclude (assigned to other request types): ${excludedNames}")
validComponents = allComponents.findAll { !(it.name in excludedNames) }
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Kadir SELÇUK I guess I should have translated your comment as well, but I only translated the script from the translator. Now I have translated your comment, and you mentioned updating the add-on, which I did to version 8.49.0, and it fixed the issue. Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.