How do I add the Modify field descriptions script?

Hi,

Using ScriptRunner for JIRA 5.1.6, when I add the script as shown on the Modify Field Descriptions page - https://scriptrunner.adaptavist.com/latest/jira/recipes/behaviours/modify-field-descriptions.html, into the Add a Custom script validator into the Inline script area on the validator, I get Static Errors - Static type checking - cannot find matching method. It lists the method for each of the def statements in the script. It also says Please check if the declared type is right and if the method exists.

I also see in the referenced document above, that this feature is available in version 5.1.7, yet the latest available to download for JIRA Server is 5.1.6. The code I inserted into the Custom Script Validator is:

def formField = getFieldById(getFieldChanged())
def descField = getFieldById("description")

def priority = formField.getValue()
if (priority == "1") { // Blocker or "Highest", priority
    descField.setHelpText("Please explain why priority is Blocker.")
    descField.setRequired(true)
}
else {
    descField.clearHelpText()
    descField.setRequired(false)
}

Please let me know how I can use this script as I would like to add the red warning messages on the fly when a user selects a particular option of a checkbox field - single select. Also, are there some import statements that need to be included in the script?

Thank you,

Joe Pursel

1 answer

1 accepted

1 vote
Jenna Davis Community Champion Sep 27, 2017

Hello, 

This script needs to be used as a behaviour. You can press '.' in JIRA, type 'Behaviours' then create a behaviour on the description field using this script. 

There are some more in depth instructions within the behaviour documentation here: https://scriptrunner.adaptavist.com/5.1.7/jira/behaviours-overview.html

Please let me know if you need any help! :)

Jenna

Hi Jenna,

Thank you for the link to the instructions. I created a Behaviour and initialized it. My script does not have errors, however when the Yes option in the checkbox field is selected, the help text does not appear. Below is my code.

def formField = getFieldByName("Is this a 911 Change Request")
def Yes = formField.getValue()
if (Yes == "1") { //If the user selects Yes to the 911 question, this message will appear as help text below the field.
formField.setHelpText"A Change Management 911 request will be prioritized over all other work within the relevant SeSu line of business. Please note that any Change Management 911 request requires Level 8 approval. Upon submission of a 911 request the following people will be notified. Seller Support Command Center/HotDesk, the Level 8 approver you indicate in this form and the Seller Support Change Management leadership team."
formField.setRequired(true)
}
else {
    formField.clearHelpText()
    formField.setRequired(false)
}

Please let me know if you have any suggestions.

Thank you,

Joe

Jenna Davis Community Champion Oct 06, 2017

Your string after 'setHelpText' needs to be enclosed in parenthesis like so, 

formField.setHelpText("A Change Management 911 request will be prioritized over all other work within the relevant SeSu line of business. Please note that any Change Management 911 request requires Level 8 approval. Upon submission of a 911 request the following people will be notified. Seller Support Command Center/HotDesk, the Level 8 approver you indicate in this form and the Seller Support Change Management leadership team.")

Also, setHelpText() is a deprecated method. It may still work for you, but setDescription() is recommended for use now. :)

Please let me know if you have any other problems getting this to work!

Jenna 

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

182 views 0 4
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