Behaviours Plugin- Groovy script does nothing sometimes without an error message

Yaron Kufert February 24, 2013

Hi, I've upgraded my Jira as well as its plugins and I have problems with the following Behaviours plugin script:

FormField formOption = getFieldByName("select example")
FormField formUserField = getFieldByName("Preview")
FormField formMailOption = getFieldByName("Email template")
tamplate = formMailOption.getFormValue()
tamplate = tamplate.replaceAll(' ','_')
def input = new File('mail/template/'+tamplate)
formUserField.setFormValue(input.text)
if (formMailOption.getFormValue() == 'Send solution') {
	formOption.setHidden(false)
	formUserField.setFormValue(input.text.replaceAll('\\$\\$SOLUTIONS',''))
} else {
	formOption.setHidden(true)
}

The behaviour work sometimes and on other times does nothing. I've opend the same issue in two browser windows and changed this behaviour field, on one window it workd and in the other it didn't. after refreshing the page sometimes it worked, and again, some time it didn't... there are no error messages in either of Jira's logs.

What am I doing wrong? how can I debug this? Thanks.

2 answers

1 accepted

1 vote
Answer accepted
Yaron Kufert February 25, 2013

Since I had no way to debug this, I gave up on the behaviour plugin and wrote it using jquery:

AJS.$("#customfield_10402").bind("change", function () {
		var selected = AJS.$(this).val();
		// show solution panel if needed
		var solutionPanel = AJS.$("#customfield_10404").parent();
		if (selected == 'Send solution') {
			solutionPanel.slideDown();
		} else {
			if (solutionPanel.is(":visible")) {
				solutionPanel.slideUp();
			}
		}
 		// load template
		var file_name = selected.split(' ').join('_');
		AJS.$.ajax({
			url: "/mail/template/"+file_name,
			type: "GET",
			data: ({projectsOnly : "true"}),
			dataType: "html",
			success: function(template){
				AJS.$("#customfield_10403").text(template);
				if (selected == 'Send solution') {
					sendSolutionTemplate = template;
				}
			}
		});
	});

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.
February 27, 2013

Sorry, been on holiday.

formMailOption.getFormValue()

won't work post-jira 4.3, it will give you the ID of the Option object. It should be Field.getValue().

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events