Automation rule encountered newline and failed

Paula Manildi April 6, 2021

Is there a way to copy a field (i.e. the Summary) during a rule to create a new issue WITHOUT encountering this error:

 

The summary is invalid because it contains newline characters. (summary)

2 answers

1 accepted

0 votes
Answer accepted
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 6, 2021

Hi Paula,

Yes, you should be able to do that. What exactly are you trying to do? Or can you share the rule that you have so far? 

Paula Manildi April 6, 2021

The rule creates a related issue and sets the summary and description by copying from the parent issue and, for the summary, appends:

{{issue.summary}} Access [Security KnowBe4+Git+AWS] 

Paula Manildi April 6, 2021

I need to strip the newline from the Summary before it is copied to avoid the error.

Bill Sheboy
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 Leaders.
April 6, 2021

Hi @Paula Manildi 

I wonder how the newline got on your summary.  Doing this should remove it:

{{issue.summary.trim()}}

Best regards,

Bill

Paula Manildi April 6, 2021

I will try this [what if the last character ISN'T a newline - will a trim work just to remove unseen character or space but not a real character?] Thanks!

Bill Sheboy
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 Leaders.
April 6, 2021

I believe trim() removes any whitespace characters at the start or end of the field:

https://support.atlassian.com/jira-software-cloud/docs/smart-values-text-fields/#Smartvalues-textfields-trim()

Like John Funk likes this
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 6, 2021

Also, are you wanting to copy the Summary over from the initial ticket? If so, then it would look like:

{{triggerissue.summary}} Access [Security KnowBe4+Git+AWS]

Paula Manildi April 6, 2021

Copy Description from Current issue seems to be working fine.

Like # people like this
Paula Manildi April 8, 2021

Configuration change is working - since I am not going to try to put a newline in an issue I just have to monitor. The original issue probably came from a cut and paste.

Like John Funk likes this

I have a solution for this: use {{issue.summary.replaceAll("\n", "")}} to remove all newline characters ("\n") instead of {{issue.summary}}.

Konstantin Gagac September 29, 2022

Hi, 

i've tried your method {{issue.summary.replaceAll("\n", "")}} , but in one case i got an issue on " is invalid because it contains newline characters"

on "lorem p\n ipsum" input text (p\n is aka Part number)

May be you have any insights and ideas? 

Hi @kon

Can you clarify your case further? are you cloning an issue and the content "lorem p\n ipsum" is from the summary of the source issue?

Konstantin Gagac September 29, 2022

Hi, Phong, 

actually my rule is for description field (but i think idea is same as with summary)

i am copying part of description to summary and want copy without line breaks (otherwise summary will not take it)

{
"fields": {
"summary": "{{issue.description.abbreviate(254).replaceAll("\n", " ")}}"
 }
}

in most cases it works well, except of when user entered p\n to description "lorem p\n ipsum"

Bill Sheboy
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 Leaders.
September 30, 2022

Hi @Konstantin Gagac 

What are you expecting the outcome to be for that replacement?

When you use "\n" in the replaceAll() and other functions, it represents the newline character, and not the literal value.

Kind regards,
Bill

Hi @Konstantin Gagac
The previous function that I mentioned works fine via the Inteliji IDE (Java JDK 8) but somehow doesn't work with Jira:

image.png

Anyway, I retested in the Jira Automation and found this correct one:


{{Description.replace("\\n", "")}}

(Note: Kindly notice that it should be "\\n" with double "\\")

 

Test result:

Screen Shot 2022-10-01 at 12.22.14.png


Like # people like this
Konstantin Gagac October 2, 2022

Hi, 

Thankx, i checked your suggestion anf yes it works with replace, but not with replaceAll

i will test with replace for longer time

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events