New to Behaviors

Daniel Krueger October 26, 2015

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... =(

Daniel.krueger@lacek.com

 11:55:: Tried Jeff's suggestion. Still nothing..

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Jeff Louwerse
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 26, 2015

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.

0 votes
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 26, 2015

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

A November 3, 2015

Hi Kristian, Above script returns null everytime

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 3, 2015

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

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 5, 2016

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

0 votes
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.
October 26, 2015

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events