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
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
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)
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
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: