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?
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"); checkIssueType(); }); AJS.$(document).bind('dialogContentReady', function(event, dialog) { console.log("Executing document.bind.dialogContentReady"); checkIssueType(); }); 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" AJS.$("#summary").val("randomtext"); summaryField.hide(); } else if(projectField == "Project Z (ZZZ)" || projectField == "AnotherIssuetype (AIT)"){ //to escape this error "summary required" AJS.$("#summary").val("randomtext"); summaryField.hide(); } else{ if(AJS.$("#summary").val() == "keine Aenderung notwendig") AJS.$("#summary").val(""); summaryField.show(); } }; </script>
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.