Hi,
In Jira server, I try to set the priorty field according the value of two custom fields : Criticity and Impact. For that, I use behaviours (script runner). Currently, my script set the priority field correctly, but I can't set it when the user selects the values in the custom fields (dynamically).
Here is my code :
def fCriticity = getFieldById( "customfield_10600" )
def fImpact = getFieldById( "customfield_10601" )
def fpriority = getFieldById( "priority" )
def fpriority0 = getFieldById( "priority-field" )
fpriority.setReadOnly( true )
String vCriticity = (String) fCriticity .getValue()
String vImpact = (String) fImpact.getValue()
if ( ( vCriticity == "Block" ) && ( vImpact == "Strong" ) )
{
fpriority.setFormValue( 1 )
fpriority0.setFormValue( "Very high" )
}
if ( ( vCriticity == "Block" ) && ( vImpact == "Medium" ) )
{
fpriority.setFormValue( 2 )
fpriority0.setFormValue( "High" )
}
if ( ( vCriticity == "Block" ) && ( vImpact == "Low" ) )
{
fpriority.setFormValue( 3 )
fpriority0.setFormValue( "Medium" )
}
if ( ( vCriticity == "Major" ) && ( vImpact == "Strong" ) )
{
fpriority.setFormValue( 2 )
fpriority0.setFormValue( "High" )
}
if ( ( vCriticity == "Major" ) && ( vImpact == "Medium" ) )
{
fpriority.setFormValue( 3 )
fpriority0.setFormValue( "Medium" )
}
if ( ( vCriticity == "Major" ) && ( vImpact == "Low" ) )
{
fpriority.setFormValue( 4 )
fpriority0.setFormValue( "Low" )
}
if ( ( vCriticite == "Minor" ) && ( vImpact == "Strong" ) )
{
fpriority.setFormValue( 3 )
fpriority0.setFormValue( "Medium" )
}
if ( ( vCriticity == "Minor" ) && ( vImpact == "Medium" ) )
{
fpriority.setFormValue( 4 )
fpriority0.setFormValue( "Low" )
}
if ( ( vCriticity == "Minor" ) && ( vImpact == "Low" ) )
{
fpriority.setFormValue( 4 )
fpriority0.setFormValue( "Low" )
}
I tried with underlying, but nothing works.
Could you help me please ?
Thank you.
Nath
Hi,
When I use this behaviour, the value is updated in the transition, but not the image (arrows). And the value stored is not right. What can I do to solve my problem ?
Nath
Hi,
That's weird, are you sure you do not have any side operation that updates the priority ?
Antoine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Antoine,
Yes, I'm sure. Nothing else updates the priority. I don't understand why it's OK when we are in the transition view and why it's KO in the issue view.
Nath
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You could maybe try to add
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.component.ComponentAccessor
def issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService)
underlyingIssue.store()
issueIndexingService.reIndex(underlyingIssue)
in the script, but this will only work if issue is created already (so underlyingIssue exists).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can do it in a listener/postfunction instead of behaviours. This means you probably need to put the priority only on view issue screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Is this script bound to both Criticality and Impact fields in your behaviours settings ?
Antoine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In that case you can debind it from the priority field and bind it to Criticality and Impact fields, that should do the trick. Behaviours will listen to an update on those fields and update priority accordingly.
Antoine
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.