Behaviours Initialiser Function not working

I cannot get the following Initialiser Function code to work.

log.error "START INITIALISE"
if (getActionName() == "Create Issue") {
FormField desc = getFieldById("description")
desc.setFormValue("Major")
} 
log.error "END INITIALISE"

However if I move this code to the usual field mapping server side scripts pane it works just fine. The trouble is i want this code to only fire once on initial presentation of the "Create Issue" screen, so i need to be in the Initialiser section.

Any ideas why the Initialiser Function of the Behaviours plugin is not working for me?

In debug mode I am not even getting the error log messages so the entire Initialiser Function seems to be ignored.

JIRA 6.3.7

Scriptrunner 3.0.10

 

7 answers

is there any update on this problem? I'm also having same issue. 

Regards, 

Murat

I got the same problem ... logging runs through - all outputs are within the logs, but the description is not set sad

I mapped the behaviour to 4 projects with a specific issue type. The Configuration looks like this:

image2015-6-22 10:31:29.pngI am on JIRA 6.3.15 and Scriptrunner 3.0.16.

0 vote

Should work... looks OK... can you paste a screenshot of the behaviour config? The page that shows the connection between fields and server side scripts. Have you mapped the behaviour to a project(s) / issuetype(s) combination?

Hi Jamie,

I am actually trying to do this for the Priority field. I need to remove from view for 1 project the MoSCoW priority values we also have. Here is my Behaviours config -

behaviours.PNG

I can remove the priority options I don't need but i can't get the Initialiser to run to set the default to "Major" rather than the invalid "MUST" which is the system default.

On initial form load I get what is in the image below. "MUST" will disappear from the options once i then choose something.

 

I have since tried to get the Initialiser Function to work on other custom fields but nothing happens, so I dont believe this is specific to me trying to manipulate the system Priority field.

 

priorities.png

 

 

I have been experiencing similar issues as raised. Not able to get the initialiser to function or debug lines logging. Using JIRA 6.4.3, ScriptRunner 3.0.16. My initialiaser script is a simple intialise a user picker custom field as the "current user": import com.onresolve.jira.groovy.user.FormField import com.onresolve.jira.groovy.user.FieldBehaviours import com.atlassian.jira.ComponentManager log.debug("--------------------This is to test Behaviours Logging----------------") def rejectedWithdrawnByField = getFieldByName("Rejected / Withdrawn By") def currentUserName = ComponentManager.getInstance().getJiraAuthenticationContext().getUser().getName() rejectedWithdrawnByField.setFormValue(currentUserName) log.debug("Rejected Withdrawn By: " + rejectedWithdrawnByField.getValue())

Hi Conor,

I've tried your code and it works. This is the screenshot of the result:

 

Screen Shot 2015-05-28 at 10.36.35.png

Is your initialiser function in the right mapping? Wrong issue type?

Screen Shot 2015-05-28 at 10.43.22.png

 

You may try to create a new test behavior with: Mapping: * Issue types: Any issue type * Projects: your project initialiser function: log.error "START INITIALISE" This is the most basic/clean case we may use to start to investigate. Can you see that message on the log when you create an issue?

@Conor McCooey

I think this bug can be related to this one:
https://jamieechlin.atlassian.net/browse/GRV-724


I am going to investigate further, I'll update that ticket when finished.

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

163 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