How do I add the Modify field descriptions script?

Joseph Pursel September 26, 2017

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
Answer accepted
Jenna Davis
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.
September 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

Joseph Pursel October 2, 2017

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
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.
October 6, 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 

Bhupesh Nagda July 30, 2018

hi @Jenna Davis

 

I wanted to ask a question, due to some weird reason behaviors are not working in our production environment and we were wondering if there was some way to use the behavior modules, classes, interfaces, like FormField etc. and import them inside a custom scripted validator inside workflows?

My support ticket to support my question:

https://productsupport.adaptavist.com/browse/SRJIRA-429

 

I want to make some fields visible/hidden and mandatory based on some field selection. I know exactly how to do it using behaviors but as i said behaviors are not working for us and we are pretty much stuck and were exploring ways to implement behaviors via other features of script runner plugin like custom script validators.

Any help would be appreciated!!

 

Thanks & Best Regards,

Bhupesh

Jenna Davis
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.
July 31, 2018

Would you be able to make a new question and send me the link to avoid derailing the response on this question since they aren't strictly related?

Short answer I can give you - you can make fields mandatory using a validator, but hiding fields in this way won't work. If you could make another question and include some details about your JIRA version and ScriptRunner versions I'll get back to you there. You also might consider submitting a new ticket on our support site, especially if you're running newer versions of the product now.

Jenna 

Like Dave Liao likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events