Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Managing different change types based on the condition

VVC
Contributor
September 16, 2024

1) Show the issue status transition on the Parent change ticket based on the following conditions:

  • If the value of "CMR Type" (single-select custom field) on the parent change ticket is "Standard" or "Normal"
  • Also, all sub-tasks must have either Cancelled or Done statuses 

Otherwise, hide the issue status transition on the Parent change ticket.

2) If the value of "CMR Type" on the parent change ticket is set to "Emergency" then no limitations apply in regard to the issue status transition.

I have already tried out by setting up some logic in the workflow -> Conditions as well as in ScriptRunner but it's not working as expected.

CMR TYPE Workflow Logic.png

2 answers

1 accepted

1 vote
Answer accepted
Sergei Troshin
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 19, 2024

Hi VVC,

I think there is no reason to use ScriptRunner behaviors.

If I understood you correctly, you should try something like this:screen.png
Hope it will help you!

VVC
Contributor
September 20, 2024

Thanks Sergey!! I will give this a try a let you know how it goes.

0 votes
VVC
Contributor
September 16, 2024

I have added the below code in the behaviors initializer and mapped for the parent change issue type, also tried mapping to both parent and child change but to no luck. Any suggestions on the workflow or Script Runner behaviors code?

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def parentIssue = issueManager.getIssueObject(underlyingIssue.getParentId())

// Check if all sub-tasks are either "Cancelled" or "Done"
def allSubTasksDoneOrCancelled = parentIssue.getSubTaskObjects().every { subTask ->
def status = subTask.getStatus().getName()
status == "Cancelled" || status == "Done"
}

// Show or hide parent issue status transitions based on the value of "CMR type"
if (allSubTasksDoneOrCancelled) {
def cmrTypeValue = cmrTypeField.getValue()
if (cmrTypeValue == "Normal" || cmrTypeValue == "Standard") {
// Show the transition
getFieldById("action_191").setHidden(false)
} else {
// Hide the transition
getFieldById("action_191").setHidden(true)
}
}

 

VVC
Contributor
September 18, 2024

Any leads on this issue please?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
9.12.
TAGS
AUG Leaders

Atlassian Community Events