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

Setting field help text using scriptrunner behaviour

flaimo February 3, 2018

I tried to change the help text of a field with Scriptrunner Behaviours according to https://scriptrunner.adaptavist.com/5.3.1/jira/behaviours-api-quickref.html with setHelpText(), but it somehow adds an additional red text, instead of replacing the small gray text under the field.


How can I do this?

Screen_Shot_2018-02-02_at_09_41_20.png

My initializer script:

 import static com.atlassian.jira.issue.IssueFieldConstants.*
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.UserLocaleStore
@BaseScript FieldBehaviours fieldBehaviours

def currentUser = ComponentAccessor.getJiraAuthenticationContext().loggedInUser
def userLanguage = ComponentAccessor.getComponent(UserLocaleStore).getLocale(currentUser).language
def summaryLabel = "Staff Member Name"
def componentsLabel = "Organizational Unit"
def katTeamLabel = "Kanban Team"
def katTeamHelp = "Optionally define of which interdisciplinary teams the employee is part of."

getFieldById("summary").setLabel(summaryLabel)
getFieldById("summary").setRequired(true)
getFieldById("components").setLabel(componentsLabel)
getFieldById("customfield_12430").setLabel(katTeamLabel)
getFieldById("customfield_12430").setHelpText(katTeamHelp)

 

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
3 votes
Answer accepted
Thanos Batagiannis _Adaptavist_
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 26, 2018

Hi Flaimo, 

In that case you will need 

getFieldByName("TextField").setDescription("This is a description from Behaviour")

Let me know if this does the trick.

Regards, Thanos

flaimo February 27, 2018
Thanos Batagiannis _Adaptavist_
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 27, 2018

That's a fair point Flaimo, we will fix it. Thanks for pointing this out. 

Pandora Atlassian Administrator November 6, 2019

This is still not updated on the API Quick Reference.  It's a rather difficult problem to google too, since there are so many examples that modify the "Description" *Field* itself.

https://scriptrunner.adaptavist.com/latest/jira/behaviours-api-quickref.html

Pandora Atlassian Administrator November 6, 2019

After playing around with the setDescription() method, it seems like it would be extremely useful to have some kind of resetDescription() method to change it back to the unmodified text (e.g. what's set in the Field Configuration).

Basically, we have a use-case where our user wants to conditionally set the description of a field, when a specific value is selected in another field.  setDescription() lets us do this for that specific value, but if the user then changes their choice to a value that should *not* modify the description, it continues to display the modified description.

The only workaround I could think of here would be to abandon setting a description in the Field Configuration entirely, and use setDescription() calls in the Behaviour exclusively (for both positive and negative cases)

Balázs Ferenczi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 23, 2020

Still not updated

(https://scriptrunner.adaptavist.com/5.7.1.1-p5/jira/behaviours-api-quickref.html?utm_source=product-help)

But at least this is the first thing that pops up after googling.

Like Dave Liao likes this
Daniel Garcia August 9, 2020

I would have expected setHelpText to Set Help Text, but it styles it like an error. I tried to restyle it using CSS but there isn't enough difference between "help text" and a real error to make the selectors work.

TAGS
AUG Leaders

Atlassian Community Events