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.
Does anything happen or not?
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.