2015-10-26_9-30-05.pngI'm new to Behaviors and I'm trying to simply set the default value for the description field. I'm not getting the script to run. and I'm not sure how to turn on logging.
Atlassian JIRA Project Management Software (v6.3.9#6339-sha1:46fa261)
Can someone help me out with this?
FormField formField = getFieldByName("Description")
formField.setFormValue("Please enter description")
Thanks for the reply, but nothing is working... =(
11:55:: Tried Jeff's suggestion. Still nothing..
Community moderators have prevented the ability to post new answers.
For the description field part of your question.. the field name is "description" not "Description". If ever in doubt, Edit an issue and do an "inspect element" on the field.
Note I am using JIRA 6.3..
<textarea class="textarea long-field wiki-textfield long-field mentionable" id="description" name="description" rows="12" data-projectkey="ADG" wrap="virtual"></textarea>
The fine folks above have answered the logging part already.
Hi Daniel,
An example of using logging with Script runner can be found here.
Also I have enclosed an example behaviours script on how to set some help text for the description field which you may find useful.
import com.onresolve.jira.groovy.user.FieldBehaviours import com.onresolve.jira.groovy.user.FormField // Import log4j import org.apache.log4j.Logger import org.apache.log4j.Level // Set the log level to DEBUG log.setLevel(Level.DEBUG) // Get the Description field and Value in Jira 6.4.12 and above def descField = getFieldById("description-wiki-edit") // def descField = getFieldByName("Description") // Use within older versions of Jira. def descFieldVal = descField.getValue() // Log the value of the description field log.debug(descFieldVal) // If the description is Null then set some help text if(descFieldVal == null ){ descField.setHelpText("Please enter a Description.") }
I hope this helps
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Amar, Can you please let me know what version of JIRA and Script Runner you are using? Also can you please post how you have configured your script and what an extract of where the error appears in the atlassian-jira.log log file. Thanks Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Amar, I have tested the above code on both Jira 6.4 and Jira 6.3 as a behaviour set on the description field and it functions correctly for me by providing some help text asking the user to enter a description. If you are still experiencing issues with this code can you please provide a screenshot of the configured behaviours and log extracts. Thanks Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Daniel,
You can have a look at https://scriptrunner.adaptavist.com/latest/jira/behaviours-overview.html#_examples
And for your 'turn on logging' question you can have a look here: https://scriptrunner.adaptavist.com/latest/jira/getting-help.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.