Forums

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

Design template value of custom field using behaviours

Dan27
Contributor
February 17, 2019

Hi,

I made a script that make a template value in custom field (type text multi).

I would like to bold some of the lines.. but without success..

How can I do it? * didn't work and <b> didn't work too.

 

This is my script:

import com.atlassian.jira.component.ComponentAccessor

//def summary = getFieldById("summary").value
//String summaryCAR = summary.toString().substring(0,3);

def desc = getFieldById("customfield_XXXXX")

def defaultValue = """bla bla bla bla bla bla

*bla bla bla*

bla bla bla

<b>bla bla bla</b>
""".replaceAll(/ /, '')

 

if (! underlyingIssue?.description)
{
desc.setFormValue(defaultValue)
}

1 answer

1 vote
Maksim Smetannikov
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.
February 17, 2019

Check the Visual/Text editor type on the issue creation form just in case)

That's correct. And should work:

*bla bla bla*

 The visual editor should have bold text. The text editor should be marked with asterisks.

Maksim Smetannikov
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.
February 17, 2019
Dan27
Contributor
February 17, 2019

Thanks! @Maksim Smetannikov  :) 

I worked, but only in create screen.

I would like it to work on edit screen too...

Maksim Smetannikov
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.
February 17, 2019

It should be simple:

if (!underlyingIssue?.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_XXXXX")))  

desc.setFormValue(defaultValue)
}

 If I understand you correctly :)

Dan27
Contributor
February 18, 2019

@Maksim Smetannikov  , Unfortunately , This template is still showing only in create screen and not in view\edit screen..

Maksim Smetannikov
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.
February 18, 2019

I corrected the previous comment-it works on edit screen.

How do you expect this to work on the view screen? After all, the default behavior of jira: do not display empty fields on the view screen. :(

Dan27
Contributor
February 18, 2019

@Maksim Smetannikov  You right, I meant only edit screen... Still not working with you updated answer..

Dan27
Contributor
February 18, 2019

@Maksim Smetannikov  I found out that when I'm opening the edit screen, the template didn't shown, But when I click on 'Visual' It is shown.. What happened there? visualview.JPG

Maksim Smetannikov
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.
February 18, 2019

Perhaps you have missed some small detail. Here is your code with my changes and it works on edit screen:Selection_334.png

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events