Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Setting field help text using scriptrunner behaviour

thackmando May 15, 2018

I want to add description help text for the reporter field via behaviours in script runner to include html links as this can't be applied in the normal format of editing descriptions in JIRA admin set-up.

Please can you provide a dummy example that I can apply for a) Reporter (help text to a web link) and also b) to a custom field that is a user picker format.

2 answers

Suggest an answer

Log in or Sign up to answer
2 votes
Marcos Sanchez
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.
May 18, 2018

Hi,

 

With a behaviour, adding the field(s) that you want to affect, you can use this script to add a help text for it.

getFieldById("reporter").setHelpText("HELP TEXT <a href=\"www.google.com\">HELP</a>")

 

Replacing "reporter" by the id of the field you can define which field to use and you can use multiple fields by adding them.

Official Docu here.

 

As an example, I did it with the Reporter field:

2018-05-18_12h52_23.png2018-05-18_12h52_44.png

 

Hope it helps.

 

Regards.
Marcos

Alicia Pena September 12, 2018

Thanks for the example. I'm trying to add default text to a Root Cause field.  I tried two different ways, but when I save it and open a jira it still doesn't show up.  I checked that my behaviors modules were enabled.   Anyone know what might be wrong?

Playing with behaviors plugin:

1.  I set the mappings to only Incident and Problem.

Mappings

 Incident Management System (Incident)

  Incident Management System (Problem) 

 

2.  I tried this in the behaviour settings Initialiser section but nothing showed up on the jira form:

def rootcause = getFieldById("Root Cause")

def rootcauseValue = """

        h2. Root Cause:

        h2. Workaround (solution) Actions:

        h2. Preventative/Corrective Actions:"""

if ( ! rootcause.getValue()) {

    rootcause.setFormValue(rootcauseValue)}

 

3.  I also tried this in the behaviour settings initialiser section, but still didn't work:

getFieldById("Root Cause").setHelpText("Root Cause: \nWorkaround solution Actions: \n Preventative/Corrective Actions:")

 

Anyone know what I'm doing wrong here?

Daniel Miks April 17, 2019

Hi @Alicia Pena 

In your second example it will work if you change the name Root cause in row 1 to ("customfield_xxxxx")

Where xxxxx is the field Id. Now you ask getFieldById not the get Field ByName.

Hope that helps!

/Daniel

0 votes
Darin Klein February 11, 2019

I found this example that sort of worked.  Formatting is still a problem, but it does show:

 

 

def desc = getFieldById("description")

def defaultValue = """
Problem Statement: An outline of the problem we're trying to solve or task to accomplish

Solution/How: How we plan to fix or solve the issue

Definition of Done: What constitutes this task being marked as completed

Stakeholders: Who are the stakeholders? DevOps/Engineering etc? Do we need buy-in or feedback to close the task? Should get confirmation of the task being completed up to stakeholders standards before moving to done status

Notes: Additional notes so others can read the ticket and grasp extra prerequisite information
""".replaceAll(/ /, '')

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

TAGS
AUG Leaders

Atlassian Community Events