How do i get current transition screen using script runner behavior?

Hi All,

I would like to check the log file that prints the current workflow Transition Screen.

What would be the import statements and method that returns the workflow transition screen.

 

Note: The behavior is written on a field present on the transition screen 

Also, the serverside script would be executed only on Done transition

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.screen.FieldScreenManager
import com.atlassian.jira.issue.fields.screen.FieldScreen

import org.apache.log4j.Logger
import org.apache.log4j.Level
  
def log = Logger.getLogger("Behaviour for Printing Transition Screen Name")
log.setLevel(Level.DEBUG)
  
log.debug "Start of Log"
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def jpField = getFieldById("Resolution Type")
log.debug("Name of the Tranistion Screen " + getFieldScreen().name)
log.debug "End of Log"

Attached is the Screen Name found in Log after executing transition.

log-behavior.PNG

 

Expected Screen Name :

Screen-Done Transition.PNG

 

Transition Screen.PNG

 

Please help me correct the behavior script 

2 answers

Please help me with some method reference, where i can hide one of the two fields present on transition screen

 

A transition screen will have 3 fields

1. Resolution  (jira default resolution field)

2. Reason (select list field) say values are A,B,C,D,E,F

3. Comment (JIra Default Comment field)

 

I would like to write a behavior when the value of Resolution changes 

Requirements:

if resolution == Fixed then hide Reason and Comment

if resolution == Canceled, then show A,B,C values under Reason

else (for any other value of resolution) show D,E,F for Reason field

 

Is this possible?

Sorry guys, the code was all right, but i was testing on an unmapped issue type on the behaviour.

 

- Here is my code added on Resolution field 

import com.atlassian.jira.component.ComponentAccessor


def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def resolutionField =  getFieldById(getFieldChanged())
def formField = getFieldByName("Reason for Resolution") 
def customField = customFieldManager.getCustomFieldObject(formField.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def selectedOption = resolutionField.getValue() as String
def commfield = getFieldByName("comment")
// Selection for Cancelled Resolution
if (selectedOption.contains("Canceled"))
{
  def optionsMap = options.findAll {
     it.value in ["Duplicate","Logged In Error","Wont Be Fixed"]}.collectEntries {
       [
        (it.optionId.toString()) : it.value
       ]}
 formField.setFieldOptions(optionsMap) 
 formField.setRequired(true)
 commfield.setRequired(false)
}

// Selection for Rejected Transition

else if (selectedOption.contains("Rejected"))
{
  def optionsMap = options.findAll {
     it.value in ["As Designed","User Error","Env. Config","Not Reproducible"]}.collectEntries {
       [
        (it.optionId.toString()) : it.value
       ]}
 formField.setFieldOptions(optionsMap) 
 formField.setRequired(true)
 commfield.setRequired(false)
}
else
{
  formField.setHidden(true)
  formField.setRequired(false)
  commfield.setRequired(true)
}  

- Added the condition as "Execute this on Done Action"

Results

if Resolution == Fixed
else if Resolution == Canceled
else

 

Thanks

Chander

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 31, 2018 in Marketplace Apps

Marketplace Spotlight: Zephyr

Hello Atlassian Community! Each month, we run a series of Spotlights to highlight Marketplace vendors and apps that our team thinks this Community would find valuable. In last month's Spotlig...

357 views 0 1
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you