Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,557,844
Community Members
 
Community Events
184
Community Groups

Validar campo multi selección con un scriptrunner

Diego Castelli
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Mar 25, 2023

Buen día, 

Quiero crear un script runner de jira software para que cuando se presione el botón 'Resolver' en un flujo valide un campo a nivel de pantalla que se llama 'Es incidente de Seguridad?' y que solo pueda tener el valor cascadeOption(12309) si el valor no es el indicado enviar un mensaje de error en pantalla que indique 'No puede continuar adelante dado que es un incidente de seguridad' y por supuesto que se interrumpa la acción manteniendo al proceso en el estado actual. (No permitir hacer la transición)

Estoy manejando la versión de jira JIRA v7.3.5 

He implementado posibles soluciones pero no andan, acá va una versión

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.fields.Field
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issue = ComponentAccessor.getIssueManager().getIssueObject(issue.getId())
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Es incidente de Seguridad?")
def fieldLayoutItem = ComponentAccessor.getFieldLayoutManager().getFieldLayout(issue).getFieldLayoutItem(customField)

def fieldValue = issue.getCustomFieldValue(customField)
def correctValue = ComponentAccessor.getOptionsManager().findByOptionId(12309)
log.debug("Valor del campo 'Es incidente de Seguridad?': " +fieldValue)
if (fieldValue != correctValue) {
String errorMessage = "No puede continuar adelante dado que es un incidente de seguridad"
log.error(errorMessage)
// ComponentAccessor.getFieldLayoutManager().getFieldLayout(issue).getFieldLayoutItem(customField).getFieldLayout().getRenderer(issue, customField).setErrors(Map.of("customfield_" + customField.getIdAsLong(), errorMessage))
return false
}

return true

 

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events