Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
Community showcase
Published in Apps & Integrations

Send an Email or Publish to Confluence - What should you do with your release notes?

Background When you hear the words ‘Release notes’, almost always you think of an unsolicited email from a software vendor. But I am here to tell you that from our data, sending release notes via E...

131 views 1 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you