Hello
I have copied and adjusted a code from here. I just have one issue with that. I want to populate summary field based on Select List (cascading). When I run sucessfully this code, it returns the value in this format: Objednávka [null:Audit staff, 1:Travel Tickets]. Is it possible to get rid of the null, parenthesis and the number? I just need the text from the field. I spend like 4 hours looking for the solution but nothing worked for me.
Could you please take a look at my code?
import com.atlassian.jira.component.ComponentAccessordef customFieldManager = ComponentAccessor.getCustomFieldManager()def myCustomField1 = customFieldManager.getCustomFieldObjectByName('Typ objednávky a předmětu')def value1 = issue.getCustomFieldValue(myCustomField1).toString()def concatValue = "Objednávka" + " " + value1issue.setSummary(concatValue)
Hi,
when you get the value from a cascading field Jira will return a Hashmap you can confirm it like that
def value1 = issue.getCustomFieldValue(myCustomField1)
log.warn(value1.getClass())//will return ==> class java.util.HashMap
Then we just need to know how to access to the value inside the hashmap, you will need to know the key (i assume Jira will not change the key everytime i want to access it)
so i just need to log the value i get like that
log.warn(value1)//return [null:Test, 1:test]
Then to access my first value i can do this
def firstValue = value1.get(null)
def secondValue = value.get("1")// the key are string
Hello Mohamed.
Thank you for your advice. I was not able to make it running but I got help from someone else. We made it running with ScriptRunner Behaviours.
The code for the solution:
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.