• Community
  • Products
  • Jira Software
  • Questions
  • Have two custom fields in create screen - Impact and Severity with values low, medium and high in select lists. When any user chooses the following values, priority custom field needs to be set automatically

Have two custom fields in create screen - Impact and Severity with values low, medium and high in select lists. When any user chooses the following values, priority custom field needs to be set automatically

Dinesh Dhinakaran
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 4, 2013

case 1

impact = low severity = low then priority= low

case 2

impact = low and severity is medium then priority = low

case 3

impact = low and severity is high then priority = medium

case 4

impact = medium severity = low then priority= medium

case 5

impact = medium and severity = medium then priority = medium

case 6

impact = medium and severity = high then priority = high

case 7

impact = high severity = low then priority=high

case 8

impact =high and severity is medium then priority = high

case 9

impact = high and severity is high then priority = critical

8 answers

2 votes
Christian Czaia _Decadis AG_
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.
February 4, 2013

You can do this using the behaviours plugin...scripting is up to you though:

https://marketplace.atlassian.com/plugins/com.onresolve.jira.plugin.Behaviours

Dinesh Dhinakaran
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 4, 2013

Please guide me to write script

Dinesh Dhinakaran
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 4, 2013

hi how i can use that plugin can i have any scripts in place

1 vote
Renjith Pillai
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.
February 4, 2013

If the relation between impact and severity with priority is fixed, why do you want to show the priority field itself in the screen? Accept the two values from the user for impact and severity and automatically set the value of priority in the post function using script runner plugin.

https://jamieechlin.atlassian.net/wiki/display/GRV/Script+Runner

0 votes
Dinesh Dhinakaran
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 5, 2013

Hi Please correct my script it is not working

import com.onresolve.jira.groovy.user.FieldBehaviours

import com.onresolve.jira.groovy.user.FormField

FormField priority = getFieldById("priority")

FormField impact = getFieldById("impact") // Your customfield

Object impactValue = impact.getFormValue()

FormField severity = getFieldById("severity") // your customfield

Object severityValue = severity.getFormValue()

if((impactValue== "Low") && (severityValue == "Low"))

{

priority.setFormValue(Low)

}

if((impactValue== "Low") && (severityValue == "Medium"))

{

priority.setFormValue(Low)

}

if((impactValue== "Low") && (severityValue == "High"))

{

priority.setFormValue(Medium)

}

if((impactValue== "Medium") && (severityValue == "Low"))

{

priority.setFormValue(Medium)

}

if((impactValue== "Medium") && (severityValue == "Medium"))

{

priority.setFormValue(Medium)

}

if((impactValue== "Medium") && (severityValue == "High"))

{

priority.setFormValue(High)

}

if((impactValue== "High") && (severityValue == "Low"))

{

priority.setFormValue(High)

}

if((impactValue== "High") && (severityValue == "Medium"))

{

priority.setFormValue(High)

}

if((impactValue== "High") && (severityValue == "High"))

{

priority.setFormValue(Critical)

}

0 votes
DanielG
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.
February 5, 2013

Please, too long tittle, edit it !

0 votes
Mizan
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.
February 5, 2013

If you are new to behavoiurs plugin things will become more simpler if you go through the documentation of the plugin first , there are many examples provided in the documentation .

Below is an untested script , you will have to modify it accordingly

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField

FormField priority = getFieldById("priority")

FormField impact = getFieldById("impact") // Your customfield
Object impactValue = impact.getFormValue()


FormField severity = getFieldById("severity") // your customfield
Object severityValue = severity.getFormValue()

//pseudo logic .. syntax not tested ... not exaclty as per your requirement
if(impactValue==severityValue)
{
      priority.setFormValue(impactValue)
}

Dinesh Dhinakaran
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 5, 2013

hi can i use this script for online editing

Mizan
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.
February 5, 2013

No , if the fields are editable via inline edits then the script will not work . I guess this is handled by the plugin , if not you will need to turn off inline editing from General Configurations page.

Dinesh Dhinakaran
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 5, 2013

hi mizan actuall y i cant understand some finctionality in the scripts will u transfer this script in to english please.

0 votes
3layer (expert) February 5, 2013

Hi all,

Sorry my short answer... bellow, a snippet code in Groovy (script "runner" post-function in "create" transition) used in one of our customers:

import java.util.Arrays;
import java.util.Collection;
import java.util.Map;

import webwork.dispatcher.ActionResult;
import com.atlassian.core.ofbiz.CoreFactory;
import com.atlassian.core.util.map.EasyMap;
import com.atlassian.jira.action.ActionNames
import org.ofbiz.core.entity.GenericValue;

import com.atlassian.core.ofbiz.CoreFactory
import com.atlassian.core.util.map.EasyMap
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.util.ImportUtils
import com.atlassian.jira.issue.index.IssueIndexManager
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem
import com.atlassian.jira.issue.*
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.opensymphony.workflow.InvalidInputException
import org.apache.log4j.Category

def log = null

try{
  log = Category.getInstance("log.foobarwar.groovy");
  log.debug("INICIANDO SCRIPT setPriopridade.groovy")
}catch(Throwable e){
  System.out.println("ERRO ao obter a instancia do log4j")
  e.printStackTrace();
  return
}

ProjectManager projectManager = componentManager.getProjectManager()
//IssueManager issueManager = componentManager.getIssueManager()
//issueManager.getIssueObject( "UNILTM-36" )

MutableIssue mIssue = issue //Mutable issue

if( mIssue == null ){
  System.out.println("Não foi possivel obter a instancia da tarefa")
  return
}

// Matriz no formato [[[Urgencia,Impacto],Prioridade],...]
// Critica=2, Alta=3, Média=4 e Baixa=5
def matrizDePrioridade = [[["Alta","Alto"],"2"],[["Alta","Médio"],"3"],[["Alta","Baixo"],"4"],[["Média","Alto"],"3"],[["Média","Médio"],"4"],[["Média","Baixo"],"5"],[["Baixa","Alto"],"4"],[["Baixa","Médio"],"5"],[["Baixa","Baixo"],"5"],[["High","High"],"2"],[["High","Medium"],"3"],[["High","Low"],"4"],[["Medium","High"],"3"],[["Medium","Medium"],"4"],[["Medium","Low"],"5"],[["Low","High"],"4"],[["Low","Medium"],"5"],[["Low","Low"],"5"]]

def campoUrgencia   = "customfield_10160"
def campoImpacto    = "customfield_10161"

//Pega o valor do custom field Urgencia
String fieldValueUrgencia =  (String)mIssue.getCustomFieldValue( ComponentManager.getInstance().getCustomFieldManager().getCustomFieldObject( campoUrgencia ) )?: "";

// Pega o valor do custom field Impacto
String fieldValueImpacto = (String)mIssue.getCustomFieldValue( ComponentManager.getInstance().getCustomFieldManager().getCustomFieldObject( campoImpacto ) )?: "";

//log.warn("Urgencia =" +  fieldValueUrgencia  + " e Impacto = " +  fieldValueImpacto)

//Obtem a prioridade da atual tarefa conforme urgencia e impacto
def prioridade = ""
for (prioridades in matrizDePrioridade) {
	urgenciaImpacto = prioridades[0]
//	log.warn(urgenciaImpacto)
	if (urgenciaImpacto[0].contains(fieldValueUrgencia) && urgenciaImpacto[1].contains(fieldValueImpacto)) {
		prioridade = prioridades[1]
		break
	}
}

//Valida se o usuario corrente esta somente em um grupo
if (prioridade.equals("") ) {
	log.warn("Problemas no calculo do campo Prioridade, Administrador do Sistema favor verificar a execução desta regra.")
	return
} 

// Seta o valor da prioridade calculado
mIssue.setPriorityId( prioridade )

//Persiste a tarefa com as alterações
mIssue.store()

//log.warn("Campo Prioridade setado com o valor " + prioridade + " com sucesso para issue " + mIssue.getKey())

Dinesh Dhinakaran
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 5, 2013

where can i use this script and how can i modify this to my requirement

0 votes
José Alexandre D'Abruzzo Pereira February 4, 2013

If you intend to calculate the priority of a risk, maybe you should take a look in the following plugin: https://marketplace.atlassian.com/plugins/com.ja.jira.plugin.report.riskmanagement

0 votes
atul February 4, 2013

Hi Dinesh,

Please modify this script accordingly.

Below script will work for if you want to autocopy data from one field to another. Design and modified script accordiangly and put in Description section of the field.

<script>
AJS.$(document).ready(function(){
AJS.$("input[name=customfield_xxxxx]").blur(function () {
var prjname= document.getElementsByName("customfield_xxxxxx")[0];
var summary= document.getElementsByName("summary")[0];
summary.value = prjname.value;

});

});
</script>

Good Luck!!

Dinesh Dhinakaran
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 4, 2013

hi atul,

it is not used.

Suggest an answer

Log in or Sign up to answer