Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Automate a custom field based on changing the status of an Issue

Hi, I am net to script runner and have only the basic knowledge. 

I am trying to automate an task  where we update an custom field.

The custom field is an radio button with 3 options  None , planned ,Unplanned .

the task is Each time an  story is marked as done and if this story is linked to a RM ticket we should change the type of change field to be planned or unplanned :

conditions :

If issue linked while Status = Scheduled, then “Type of change” field for issue = Planned

If issue linked while Status = Scope Freeze, then “Type of change” field for issue = Unplanned

If issue linked while Status = Code Freeze, then “Type of change” field for issue = Unplanned


1 answer

0 votes

In a postfunction for your workflow transition where the main story is being marked as done, you can add a sriptrunner post function using "custom script post function" with a script somewhat like this:

import com.atlassian.jira.component.ComponentAccessor

def issueLinkManager = ComponentAccessor.issueLinkManager
def customFieldManager = ComponentAccessor.customFieldManager
def optionsManager = ComponentAccessor.optionsManager

def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser

def typeOfChangeCf = customFieldManager.getCustomFieldObjectByName('Type of change')
def cfConfig = typeOfChangeCf.getRelevantConfig(issue)
def changeOptions = optionsManager.getOptions(cfConfig)
def plannedOpt = changeOptions.find{it.value == 'Planned'}
def unplannedOpt = changeOptions.find{it.value == 'Unplanned'}

def linkedRMIssues = issueLinkManager.getLinkCollection(issue, currentUser)?.allIssues?.findAll{it.projectObject.key == 'RM'}

if (linkedRMIssues.any{ == 'Scheduled'}) {
issue.setCustomFieldValue(typeOfChangeCf, plannedOpt )
} else if (linkedRMIssues.any{ == 'Scope Freeze'}) {
issue.setCustomFieldValue(typeOfChangeCf, unplannedOpt )
} else if (linkedRMIssues.any{ == 'Code Freeze'}) {
issue.setCustomFieldValue(typeOfChangeCf, unplannedOpt )

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events