We want to set helptext for "Description" field via behavior

Our JIRA had installed the "Script Runner" plugin.

1, We want to set helptext for "Description" field by behavior if we , the original code as below:


if(secondCategory.contains("aaaaaaaaaaaaa")){

descValue = "Request Template"
helpText= "<a href='abbbb.html'> Request Template</a>"


}

else if(secondCategory.contains("XXXXXXX")){
//description.clearHelpText()
descValue = " internal Request)"
helpText="<a href='abcd.html'> internal Request Template</a>"
}

}
description.setFormValue(descValue)
description.setHelpText(helpText)

2, According above code, if we select correct options for "Category" field, the helptext will have different value.

But, if the value of "Category"meets the first condition, the helptext works normally.

And, if we change the option(meet another condition) of "Category" field,  the value of the helptext had been set successfully(we see it in our logs), but we can't see it show on screen.

If anyone can give us some solution, thanks in advance.

 

 

 

 

  

 

 

 

 

1 answer

0 vote

Hello Meng Ge,

Your script looks almost correct to me. I wrote this script:

def secondCategory = getFieldByName("Category") // your field name here
def description = getFieldById("description")

if (secondCategory.getValue().toString().contains("AAA")) {
description.setFormValue("Request Template")
description.setHelpText("<a href='abbbb.html'> Request Template</a>")
}
else {
description.setFormValue("Interal Request")
description.setHelpText("<a href='abcd.html'> Internal Request Template</a>")
}   

This behaviour script is attached to the "Category" field, not the "Description" field.

Image of it working:

Screen Shot 2017-09-29 at 4.07.40 PM.png

 

Suggest an answer

Log in or Join to answer
Community showcase
Teodora [Botron]
Published Feb 15, 2018 in Marketplace Apps

Jira Inferno: The Nine Circles of Jira Administration Hell

If you spend enough time as a Jira admin - whether you are managing a single, mid-sized instance, a large enterprise one or juggling multiple instances at once - you will eventually find yourself in ...

1,142 views 6 19
Read article

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot