Does JIRA Server 7.3.3 supports JavaScript for Custom Fields successfully?

We've been facing some issues on the issue creation. we have many custom fields that are embedded through JavaScripts. However, sometimes the create issue scheme works perfectly and sometimes it doesn't.

Any info on why this is happening?

2 answers

I think you embedded the javascript in the custom field description in field configuration, right?

Iam also using javascript in summary description. the important thinks you have to look for are the "events" and the field configuration schemes.

Example: If you want your javascript executed for a customfield in screen for project X (each issuetype). you have implemented the javascript in the field configuration for that project. When you open create dialog and the project X is already selected the correct field configuration is loaded and the javascript is executed.
If at that moment Project Y is selected the field configuration of Project Y is loaded, if you switch to project X it will in any kind sure load the field configuration of project X but it wont execute the javascript of that X field configuration.
Iam not sure why its doing this.
So what i did is to embed my javascript in each field configuration (yes that can be alot of work, we currently have 35 different field configurations) and in my code i check the project and issuetype and then i execute whats necessary.

in this example iam hidding the summaryfield and prefill it. i override the "randomtext" the with a groovy script that is executed in create transition postfunction.

<script type="text/javascript">
AJS.$(document).ready(function(event, dialog) {
 console.log("Executing document.ready");
AJS.$(document).bind('dialogContentReady', function(event, dialog) {
 console.log("Executing document.bind.dialogContentReady");

function checkIssueType(){
    var projectField = AJS.$('#project-field').val();
 var issueTypeField = AJS.$('#issuetype-field').val();
 console.log("Project: " + projectField);
 console.log("Issuetype: " + issueTypeField);
var summaryField=AJS.$("#summary").parent();

 if(projectField == "Project X (XXX)" && issueTypeField != "AnyIssuetype (AIT)")
  //to escape this error "summary required"
    else if(projectField == "Project Z (ZZZ)" || projectField == "AnotherIssuetype (AIT)"){
  //to escape this error "summary required"

  if(AJS.$("#summary").val() == "keine Aenderung notwendig")

Maybe this gets you an idea what you can do to solve your problem

Hi Stefan, Thanks for your detailed guidance, yes we embedded the javascript in the custom field description in field configuration. But we're working in only one project but ofcourse different issue types. So would using a plugin such as ScriptRunner solve this problem? Please advise

If you have different field configurations for that issuetypes its still the same problem. the javescript has to be in each of them

The question is what you are trying to achieve.

If you want someting like dynamically prefilled custom fields in create screen then i dont believe there is a way to achieve this with scriptrunner. 
If you want to fill some customfields immediately after the issue is created then sure you could use a scriptrunner script in the create transition as postfunction.

0 votes
Steven Behnke Community Champion Jun 28, 2017

JIRA does not support javascript in customfields.

If they aren't working, are they throwing errors in the browser console? Do they work in the "full page create" operation, or do they work in the dialog?

We need more information to help you at all.

Hi Steven, Thanks for your prompt response.

Yes we are getting errors in the browser console, We want to show and hide fields based on the value selected from a custom select list. These function were working better in the previous versions of JIRA, but in this version it's not working as it is supposed to be.

Please advise :)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,521 views 15 21
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