Behaviours Initialiser Function not working

Conor McCooey March 11, 2015

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

1 vote
Martin Buchleitner June 21, 2015

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.

1 vote
Murat BALKAS June 16, 2015

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

Regards, 

Murat

0 votes
Cesare Jacopo Corzani
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.
May 29, 2015

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

0 votes
Cesare Jacopo Corzani
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.
May 27, 2015

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

 

Cesare Jacopo Corzani
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.
May 28, 2015

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?

0 votes
Heng Cheong May 26, 2015

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())

0 votes
Conor McCooey March 11, 2015

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

 

 

0 votes
JamieA
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.
March 11, 2015

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?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events