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
Community Members
Community Events
Community Groups

Replace a String with an line break in multi line field

Hello together, 

we are currently facing a problem in our internal Jira environment. We receive data from an external system and they are not possible to send it with line breaks via the API. The problem here is that we need every new data set in a new line because we have some automation scripts reading this line break. 

So now my question is: How can i replace a String with a line break? Maybe this is something I could implement via ScriptRunner. 

The current format is this: 


And the expected format would be:


 Are there any possibilities to change the data in Jira internally. 

Thanks for now, have a nice weekend. 

Best regards!

1 answer

1 accepted

2 votes
Answer accepted

Hi @Tobias 

For your requirement, you could try something like this on the ScriptRunner Console:-

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue

def issueManager = ComponentAccessor.issueManager
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def issue = issueManager.getIssueByCurrentKey('MOCK-1') as MutableIssue
def description = issue.description.replace("\\n", "\n")
issueManager.updateIssue(loggedInUser,issue, EventDispatchOption.DO_NOT_DISPATCH,false)

Please note, the sample working code above is not 100% exact to your environment. Hence, you will need to make the required modifications.

The main point is on this line:-

def description = issue.description.replace("\\n", "\n")

You will need to use the replace method to convert the \n parameter in your String which will be read as \\n to \n to enable the line break.

Below is a print screen of the ScriptRunner Console configuration:-


Below are a few test screens:-

1) This is how the text in the Description field is displayed initially:-


2) This is how the text in the Description field is after running the code above:-


I hope this helps to answer your question. :)


Thank you and Kind Regards,


Hi @Ram Kumar Aravindakshan _Adaptavist_
thanks for providing this solution it works really well. How to implement this in Jira? I think best would be to trigger it in a transition or what do you think? The best way would be after creation, but I think this could cause some problems. 

Best Regards,


Hi @Tobias

You can either do it during a Transition, i.e. using the Post-Function or even using the Listener to answer your question.

If you want to do it using the Post-Function, you could even use the Create transition, i.e. once the issue is created, the text will be re-formatted. This shouldn't cause any issues.

Thank you and Kind Regards,


Like Tobias likes this

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events