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

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

Avatar

1 badge earned

Collect

Participate in fun challenges

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

Challenges
Coins

Gift kudos to your peers

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

Recognition
Ribbon

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!

Leaderboard

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
4,556,417
Community Members
 
Community Events
184
Community Groups

Automate Fields value selection

Hi All,

Can we automate fields value selection depends on other field value using script runner?

Ex - We have custom fields 1, 2, & 3. all are single select list fields

When user selects a field value of 1, field value of 2 and 3 should automatically select depends on the field value of 1.

I am new to script runner.

Thanks in advance,

ch

1 answer

0 votes
Raziman Dom - Ricksoft
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 07, 2020

Hi Manikanta,

It is possible using behavior ScriptRunner. The below code should give you a rough idea:

/**
* List A has value 1,2
* List B has value ABC, DEF
* Purpose: Auto-populate List B from value List A
*/

import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Level
import org.apache.log4j.Logger

log.setLevel(Level.DEBUG)

final def listA = "List A"
final def listB = "List B"

def listFieldA = getFieldByName(listA)
def field = getFieldByName(listB)
def optionsManager = ComponentAccessor.getOptionsManager()

def listFieldB = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName(listB)
def listFieldBConfig = listFieldB.getRelevantConfig(getIssueContext())

def optListFieldB = optionsManager.getOptions(listFieldBConfig)
def optValueA = optListFieldB.find {it.value == "ABC"}
def optValueB = optListFieldB.find {it.value == "DEF"}

def listFieldAValue = listFieldA.getValue()

if(listFieldAValue == "1") {
log.debug("Condition passed! Update to value ABC")
field.setFormValue(optValueA.optionId)

} else if (listFieldAValue == "2") {
log.debug("Condition passed! Update to value DEF")
field.setFormValue(optValueB.optionId)

} else {
log.debug("Condition failed! Update to null")
field.setFormValue(null)
}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events