Is it possible to add a conditional custom field in create issue page

Andrew_Selvin October 13, 2013

Hi All,

Is it possible to add a conditional custom field in create issue page?

If yes, how? I have just started customising jira code, your help is appreciated.

My requirement is to display a custom field in create issue page based on specific condition of the previous drop down custom field value.

Regards

Andrew Paul S

5 answers

0 votes
RambanamP
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.
October 14, 2013

i think you are trying to show or hide field on selection of select list if yes then use following script

<script type="text/javascript">
jQuery(document).ready(function($) {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {
    callChangeFunction();
});
    callChangeFunction();
function callChangeFunction(){
        showHidField();
    // dropdown custom field change function
    $("#customfield_10625").change(function() {
        showHidField();
    });
       
}
 
function showHidField(){
    //drop down field selected value
    var dropDownFieldval =$.trim($("#customfield_10625 :selected").text());
    //test field1
        $("#customfield_10639").closest('div.field-group').hide();
    if(dropDownFieldval == 'Project'){
        $("#customfield_10639").closest('div.field-group').show();
    }if(dropDownFieldval == 'Release'){
        $("#customfield_10639").closest('div.field-group').show();
    }
}
 
});
 
</script>

Raju Adluru October 2, 2015

Hi @Rambanam Prasad

I have similar requirement, i have a radio button called Test1.

When Test1 value is yes, other custom fields ( test2, test3, test4) should show.

when Test1 values is No, other custom fields should be hidden from create screen and edit screen

Can this be done with above java script, or i should create a custom plugin and put it in .js file and .xml file?

Thanks for your help.

RambanamP
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.
October 2, 2015

yes, with above script you can do that, change from change event click event at line 10 and change the way of selected value for radio button at line 18 i suggest to add it as webresource module in plugin, check the link provided in @Bharadwaj answer

0 votes
Andrew_Selvin October 14, 2013

Thanks Bharadwaj for your quick response. I wanted to make sure this is the file, so cut the file createissue-details.jsp and placed in another location. Restarted the service, but still create issue page is shown.

I think there is someother file corresponds to it or do you have any suggestion.

Regards

Andrew Paul S

Bharadwaj Jannu
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.
October 14, 2013

I think you need to restart jira.

But changing the default files might lead to Jira corruption. So I prefer to use external things like creating plugin, adding javascript.

Tell your exact requirement which I am able to look into.

0 votes
Andrew_Selvin October 14, 2013

Hi All,

Thanks for your reply. Can anyone help me. its urgent.

I need the source code file name corresponding to the create issue page.

Since this is the first time touching the code.. still searching to find the file name.

Your help is appreciated.

Regards

Andrew Paul S

Bharadwaj Jannu
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.
October 14, 2013

{...}\Atlassian\JIRA\atlassian-jira\secure\views\createissue-details.jsp

in {...}\Atlassian\JIRA\atlassian-jira\WEB-INF\classes\actions.xml you search for CreateIssue

I donot have source code, you search for CreateIssue class file in your jira installation directory.

0 votes
Bharadwaj Jannu
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.
October 14, 2013
0 votes
Pedro Cora
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 14, 2013

Andrew,

You can probably use the features of the Workflow Toolbox plugin.

Suggest an answer

Log in or Sign up to answer