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.
I have a behaviours script and following requirement:
If user select values of cascade field as "Peter" (first option) and "New York" (Second option) then I can see the hidden field.
Can someone please help me?
def tid = getFieldByName("Name and Location");
def monthlyMaintenance = getFieldByName("Is this for monthly network maintenance");
monthlyMaintenance.setHidden(true);
if(tid.getValue() == "'Peter','New York'"){
monthlyMaintenance.setHidden(false);
}
Hi All,
Following code has worked for me but ensure the cascading custom field is available in the screen you are working on,
For Behaviour:
def cfield = getFieldByName("cascading custom field name")
Map mapValue = cfield.getValue() as Map
def value1 = mapValue.get(0).toString()
def value2 = mapValue.get(0).toString()
For Post Functions:
import com.atlassian.jira.component.ComponentAccessor
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObjectsByName('cascading custom field name').getAt(0)
def cstFldVlue = issue.getCustomFieldValue(customField)
Thanks
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.
Hi @devsuresh2005 - I tried your solution and it was slightly incorrect.
value2 should use 'get(1)' instead of 'get(0)' ;-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yay, thanks @devsuresh2005 for this - tried several other posted solutions that didn't seem to work, this one's doing it!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I use the following in a ScriptRunner post function. I'm not sure if it'll work in a Behaviour, but maybe it'll at least get you headed in the right direction.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
String unit,category,emailDestination
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
CustomField cf = customFieldManager.getCustomFieldObjectByName("Unit and Category")
Map cfVal = issue.getCustomFieldValue(cf) as Map
if (cfVal) {
String first = cfVal.get(null)
String second = cfVal.get("1")
unit = first
category = second
}
else {
unit = ""
category = ""
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Payne,
I can't get it to work :/
I saw a lot of post like yours that cast
issue.getCustomFieldValue(cf)
To Map or Hashmap or ....
But in my case, I don't know why I can't do it. The compiler cast automatically my issue.getCustomFieldValue(cf) to Double and it can't overwrite this cast.
I can't understand why, but my field value is always 0.0 (with or without value in the field)
When i put this in my code :
Map cfVal = issue.getCustomFieldValue(cf) as Map
I have this error :
org.codehaus.groovy.runtime.metaclass.MissingMethodExceptionNoStack: No signature of method: java.lang.Double.isEmpty() is applicable for argument types: () values: [] Possible solutions: identity(groovy.lang.Closure), isNaN(), inspect(), dump()
When i try another thing i saw in a different post (but similar) :
log.warn(((Map<String, String>) issue.getCustomFieldValue(cf)).get(null))
I have this error :
Cannot cast object '0.0' with class 'java.lang.Double' to class 'java.util.Map'
As I was saying, even if it display an error in the "pre-compiling" I can run this code well :
log.warn issue.getCustomFieldValue(cf).floatValue()
and I have this result :
[runner.ScriptBindingsManager]: 0.0
Do you have any idea that could make
Map cfVal = issue.getCustomFieldValue(cf) as Map
works ?
Regards,
Laurent
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.