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

Chander Inguva
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.
June 29, 2017

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

0 votes
Chander Inguva
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.
June 29, 2017

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

0 votes
Chander Inguva
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.
June 29, 2017

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?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events