Velocity compare multiline string problem description-edit

Hi,

 

I'm having trouble in comparing multi-line string. The goal is to compare the description string in case of multiple project.

I have several projects like this:

 - Project1

 - Project2

 

I have edited the description-edit.vm file like this:

 

#set ( $description_project1="template 
project
1")
#set ( $description_project2="template project
2")

#if ($description == '' && $issue.project.key == 'Project1')
#set ($description = $description_project1)
#end

#if ($description == '' && $issue.project.key == 'Project2')
#set ($description = $description_project2)
#end

 

I have a multi-line description ($description_project1).

 

When I create an issue, there is no problem because the variable $description = ''

The problem is when i click on create an issue (by default on the project1 for exemple) then switch to the project2. The variable is not equal to '' but to the value of the template of the project 1.

 

So I tried to add the following code:

#if ( ($description == '' || $description_project2 == $description) &&  $issue.project.key == 'Project2')
#set ($description = $description_project1)
#end

 

But the code above doesn't work only if I have a multi line description (if I have one word for description it works).

I tried to format the variables $description et $description_project1 with the method collapseNewlines() with no success.

I tried also to compare string with StringUtils.equals but it doesn't work either.

 

Have anyone have an idea of a solution? A solution for me will be to be able to write the variable $description_project1 on one line but i didn't find how to add a return in the string.

 

Thnak you for your answers.

 

1 answer

1 accepted

This widget could not be displayed.

Hi,

I have found a solution to avoid comparing thos string with the character return.

I added the line !$issue.getStatusObject() to compare id the issue have already have been created or not. If the status exists (open, etc...), I don't replace the description value by my template. If the status doesn't exist, I replace the text with the template.

 

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

88 views 1 0
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you