If/than statements in jira

Scott Federman September 2, 2015

I am trying to build some logic that would satisfy the following request. Is this possible in JIRA?

  1. IF Approval Needed = “Change control Approval” and Change disposition = approved
  2. AND IF change ticket status = Open
  3. AND IF Current date/time – Change Request Date >= 60 mins (some value)
  4. THEN Set Change Disposition = Agenda

 

5 answers

1 vote
Midori
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.
September 4, 2015

Implement this logic with the JIRA Automation Plugin: https://marketplace.atlassian.com/plugins/com.atlassian.plugin.automation.jira-automation-plugin

The "if" part can be easily described as a JQL filter.

The "then" part is actually an "update issue" action, where you set a new value to your field.

Simple and elegant.

1 vote
Nic Brough -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.
September 2, 2015

In what context?  Are you defining a search?  Or a post-function?

Scott Federman September 2, 2015

it would need to be a postfunction

Nic Brough -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.
September 2, 2015

Ok, you'll need some code to do it (I would do it in the script runner as usual, although there are other scripting addons) You'll need to think about the second line too - is the status you are checking the before or after transition. You could actually drop it completely if you place the post-function in the right place(s) because the status is implied by the position of the post-function (you know where it's from and going to)

Scott Federman September 2, 2015

Sumit, 

That is of interest to me. How can i do that?

Nic Brough -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.
September 2, 2015

Sorry converted that accidentally!

0 votes
Scott Federman September 3, 2015

Sumit where would i apply the code? in a post function?

Nic Brough -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.
September 3, 2015

The code given is for the Behaviours option, so you'd enter it in the add-on config screens. Post-functions are for writing data after the user commits the transition

0 votes
Sumit Kumar
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.
September 2, 2015

Below is the sample code :

{code}

FormField priority=getFieldById("customfield_XXX")
FormField impact=getFieldById("customfield_YYY")
FormField severity=getFieldById("customfield_ZZZ")
// if it's a list it has more than one value
priorityValue=priority.getValue()
impactValue=impact.getValue()
severityValue=severity.getValue()


if(severityValue.toString()=="Sev 5"){
severity.setReadOnly(true)
if (priorityValue.toString()=="P2" || priorityValue.toString()=="P3" || priorityValue.toString()=="P4" || priorityValue.toString()=="P5" ){

priority.clearError()
priority.with {
setValid(true)
setTitle ("")
setHelpText("")
}
impact.setFormValue("14624")
impact.setReadOnly(true)
severity.setReadOnly(false)

}
else {
priority.with {
setValid(false)
setHelpText("<div class=\"warningBox\">Only P2, P3, P4 and P5 are Valid</div>")
}

priority.setError("<div class=\"warningBox\">Only P2, P3, P4 and P5 are Valid</div>")


}
// severity.setHelpText("$severityValue")
// impact.setHelpText("$impactValue")
}

{code}

 

field . setHelpText can be used for debugging.


thanks,

Sumit

 

 

0 votes
Sumit Kumar
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.
September 2, 2015

Behaviors can be written and applied as well if post function doesn't suits the full requirement.

 

Thanks,

Sumit

Nic Brough -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.
September 2, 2015

Behaviours is a part of the "Script Runner" addon. Behaviours can do things to fields in the foreground before the user makes changes, rather than the post-function that would update data automatically after they commit. Which one is better depends very much on the goal. (This one sounds like a post-function)

Suggest an answer

Log in or Sign up to answer