Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Riccardo Micozzi
December 4, 2020

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

Suggest an answer

Log in or Sign up to answer
0 votes
Katy Kelly
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
September 28, 2020

Hi,

We recommend moving this question and tagging SmartBear on it as Adaptavist no longer owns Test Management for Jira. Learn more.

Please direct your TM4J Server/DC queries to tm4j-server-support@smartbear.com or TM4J Cloud queries to tm4j-cloud-support@smartbear.com. You can also visit their general support portal

Kind regards,

Katy

Adaptavist Product Support 

Jürgen Kindler
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 12, 2020

Thanks Katy.

I am clarifying how to pass the wall / gate of the support page.
( As I think, we should have corporate support here ... )

TAGS
AUG Leaders

Atlassian Community Events