Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,560,629
Community Members
 
Community Events
185
Community Groups

how to split a String into multiple String in a post-function?

Edited

Hello there,

I have a CustomField(a label) where there is the possibility to insert more than a word(for example: apple, banana, watermelon) I need to write a Post Function, using the ScriptRunner in Jira Cloud) that get che Custom Field value and split the String into 3 different String(in the example on the top, one string for one fruit), obviously if in the CustomField there is only a word I will get only 1 String.

 

For the moment i have write this peace of code:

// get custom fields
def customFields = get("/rest/api/2/field")
.asObject(List)
.body
.findAll { (it as Map).custom } as List<Map>

def lista = customFields.find { it.name == 'Lista' }?.value

def lista1 = (issue.fields[lista] as String)?.replaceAll(/,.*/, ' ')

 

but Now I don't know how to move forward

 

P.S: I don't know if the peace of code that i have write is okay.

 

thanks to those who will answer

1 answer

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Dec 04, 2020

What type of field have you created?  Is it text or multi-select (like a label, component or, well multi-select)?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Dec 14, 2020

Sorry for the delay.

A label is held in a similar way to multi-selects, so in your code, lista will be holding an array of label elements.

So if you iterate over that, using .getName() on each element, you'll get one value string at a time.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events