You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi there,
I'm trying to to set up a behaviour when a value contains a specific number:
Hi Alex,
thx for replying quickly. Unfortunately I'm receiving the following error:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is it possible to paste here you code so that I can perform some tests?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes of course:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Dustin Glienke just noticed on your script that on material you have this id:
customfield_164118
Is this correct? It has a six figure numerical id.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes it is correct:
Our system has a strange count system, we have not that many fields
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Dustin Glienke the following script worked for me:
def text = getFieldByName("Text field (akox)")
def multiSelectField = getFieldById(getFieldChanged())
def multiSelectFieldValue = multiSelectField.value as List
def myValues =multiSelectFieldValue.toString()
def result = (myValues =~ /\d+/).findAll()
if (multiSelectFieldValue == [null] ) {
}
else {
assert result == ["4000"]
text.setFormValue ("Found 4000")
}
Let me know if that works out for you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Unfortunately it does not work but i don't know why:
def wertus = getFieldById("customfield_63900");
def wertcn = getFieldById("customfield_63901");
def multiSelectField = getFieldById(getFieldChanged())
def multiSelectFieldValue = multiSelectField.value as List
def myValues =multiSelectFieldValue.toString()
def result = (myValues =~ /\d+/).findAll()
if (multiSelectFieldValue == [null] ) {
}
else {
assert result == ["4000"]
wertcn.setFormValue("CN")
wertus.setFormValue("US")
//text.setFormValue ("Found 4000")
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Dustin Glienke did you try following the guidelines I gave you with code? This code works on my instance without any problem. What kind of fields are wertcn and wertus?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alex,
I found a solution. The function contains is the right one. I figured out to use this 'value' instead of "value". Now it is working. Thanks for your help!
import com.onresolve.jira.groovy.user.FieldBehaviours
import org.apache.log4j.Logger
import org.apache.log4j.Level
import groovy.transform.BaseScript
def material = getFieldById("customfield_164118");
def wertus = getFieldById("customfield_63900");
def wertcn = getFieldById("customfield_63901");
def wertde = getFieldById("customfield_63902");
@BaseScript FieldBehaviours fieldBehaviours
def log = Logger.getLogger(getClass())
def multiSelectField = getFieldById("customfield_164118");
def multiSelectFieldValue = multiSelectField.value as List
def myValues =multiSelectFieldValue.toString()
// If value is null
if (myValues.contains('4000')) {
wertus.setFormValue("US")
}
if (myValues.contains('5000')){
wertcn.setFormValue("CN")
}
if (myValues.contains('4000')==false) {
wertus.setFormValue("")
}
if (myValues.contains('5000')==false){
wertcn.setFormValue("")
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.