I'm trying to get the data out of a cascading select custom field, but I'm not having much luck. This code seems to work for getting the value of the second selection, but I can't get at the first:
from com.atlassian.jira import ComponentManager import urllib import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.fields.CustomField customFieldManager = ComponentManager.getInstance().getCustomFieldManager() # Get the issue number key = issue.getKey() # Get value of the 'Revision' field revisionField = customFieldManager.getCustomFieldObjectByName("Revision") revision = issue.getCustomFieldValue(revisionField) # Get value of the 'Domain and Application' field serviceField = customFieldManager.getCustomFieldObjectByName("Domain and Application") service = issue.getCustomFieldValue(serviceField) domain=service[''] application=service['1'] # Kick off the job in Jenkins params = urllib.urlencode({'SVN_REVISION': revision, 'ISSUE_NUMBER': key, 'DOMAIN': domain, 'APPLICATION': application}) f = urllib.urlopen("http://jenkins/job/flexB-ApplicationService-trunk-jira-test/buildWithParameters?token=flexB-ApplicationService-trunk", params) print f.read()
This works for getting to the second value (service, or position '1'), but I can't seem to get the first value (domain, or position 'null'). What amm I missing here?
This is a post function in our workflow, and we're running Jira 5.1.4 with Jira Scripting Suite.
Thanks!
Bill
following way you can get cascading field value
Object value = issue.getCustomFieldValue(customField); CustomFieldParams params = (CustomFieldParams) value; if (params != null) { Object parent = params.getFirstValueForNullKey(); Object child = params.getFirstValueForKey("1"); }
https://answers.atlassian.com/questions/116569/how-to-get-the-cascading-select-value
or check this issue
https://jamieechlin.atlassian.net/browse/GRV-42
I tried with the script provided, and I get an error message:
root cause: SyntaxError: ("mismatched input 'value' expecting NEWLINE", ('<string>', 19, 7, 'Object value = issue.getCustomFieldValue(10001);\n'))
# Get value of the 'Domain and Application' field Object value = issue.getCustomFieldValue(10001); CustomFieldParams params = (CustomFieldParams) value; if (params != null) { Object parent = params.getFirstValueForNullKey(); Object child = params.getFirstValueForKey("1");
My only real change was to the getCustomFieldValue command. Do I need to make other changes?
Thanks!
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Rambanam gave you groovy/java code, whereas you appear to be using python.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
:) Well that would make sense. I'll see if I can re-engineer this. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
IIRC the value is a nested map, but if you print out the value you will see.
Try service[Null] for the root value - I think python null is "Null".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When I print the value, I get the following:
{null=flexA, 1=MortgageInsurancePremium}
I tried with [null] and [Null], and I get an error either way: Null is not defined. If I use ['null'], it doesn't error out, but the value I get on my jenkins box is "None"
Thanks!
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, python null is None. Try that, or Rambanam's method which should also work.
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.