We have 4 select list custom fields devided into two issue types. Please find the below details -
In Issue Type Observation custom fields are - Audit Type and Sub Audit Type. The Value of Sub Audit Type is - Project, Release,Training,Security,Defect
In Issue Type Auditor's Task custom Fields are - Task Type and Sub Task. The Value of Sub Task is - Project Audit, Release Audit,Training Audit,Security Audit
The Custom Field Value of Audit Type is - 10625
The Custom Field Value of Sub Audit Type is - 10639
The Custom Field Value of Task Type is - 10640
The Custom Field Value of Sub Task is - 10645
Now our requirement is in issue type observation the "Sub Audit Type" Custom Filed only show when we select the value "Project" and "Release" from Audit Type Custom Field. Similarly in issue type Audito's Task the "Sub Task" Custom Field only show when we select the value "Project Audit" and "release Audit" from Task Type Custom Field.
The value of Project is - 10800
The Value of Release is - 10801
The Value of Project Audit is - 10877
The Value of Release Audit is - 10878
To configure above mentioned things we have tried 3 different things -
i) Use behavior plugin Configuration to hide/show Sub Task and Sub Audit Type
ii) Use Java Script in the description of Sub Task and Sub Audit Type Custom Field. we have edited the description from custom field section as well as field configuration section
iii) Use both the above procedure at a time
Problem - i) When we user behavior the target field completely disappears.Target field not appearing even selecting the source field values which I have alrady mentioned
ii) When we use Java Script Target Filed some times disappeared and appeared when we select the source field values which I have already mentioned. Means working perfectly. But some time Both the source and destination field visible which is not desired. Means it behaves inconsistently.
iii) When we use both Behaviour and Javascript the Target field completely disappeared and not visible even choosing the source field values which I have already mentioned.
Our Jira Version is - 5.2.4
And Behaviour Plugin Version is - 0.5.3
1)Download atlassian-sdk rpm from below mentioned URL –
https://marketplace.atlassian.com/search?q=atlassian+plugin+sdk
Install the RPM in JIRA machine
2)Cd /home/secure/services/jira/project folder. Run the below mentioned command –
atlas-create-jira-plugin
3)Enter1
forJIRA 5
and press RETURN
4)Respond to the prompts using the information in the following table:
Define value for groupId |
com.atlassian.tutorial.javascript |
Define value for artifactId |
javascript |
Define value for version |
2.0-SNAPSHOT |
Define value for package |
com.atlassian.tutorial.javascript |
5)Pressy
to continue.
The system creates ajavascript
project folder
6)Cd /home/secure/services/jira/project/javascript/src/main/resources folder
7)Vi atlassian-plugin.xml
<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2"> <plugin-info> <description>${project.description}</description> <version>${project.version}</version> <vendor name="${project.organization.name}" url="${project.organization.url}" /> <param name="plugin-icon">images/pluginIcon.png</param> <param name="plugin-logo">images/pluginLogo.png</param> </plugin-info> <!-- add our i18n resource --> <!-- <resource type="i18n" name="i18n" location="javascript"/> --> <!-- add our web resources --> <web-resource key="javascript-resources" name="javascript Web Resources"> <dependency>com.atlassian.auiplugin:ajs</dependency> <!-- <resource type="download" name="javascript.css" location="/css/javascript.css"/> --> <resource type="download" name="javascript.js" location="/js/javascript.js"/> <!-- <resource type="download" name="images/" location="/images"/> --> <context>atl.general</context> </web-resource> <!-- publish our component --> <!-- <component key="myPluginComponent" class="com.atlassian.javascript.javascript.MyPluginComponentImpl" public="true"> --> <!-- <interface>com.atlassian.javascript.javascript.MyPluginComponent</interface> --> <!-- </component> --> <!-- import from the product container --> <!-- <component-import key="applicationProperties" interface="com.atlassian.sal.api.ApplicationProperties" /> --> </atlassian-plugin>
8)Cd /home/secure/services/jira/project/javascript/src/main/resources/js folder
9)Vi javascript.js
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(); } } });
10)Cd /home/secure/services/jira/project/javascript folder
11)Run the command atlas-package
12)It will create target folder under /home/secure/services/jira/project/javascript location
13)Cd target folder. You can found following jar - javascript-2.0-SNAPSHOT.jar
14)Upload it into JIRA
15)Your “Show/Hide Custom Field depend on another custom Field Value” should work
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Wow! What a pain this was trying to get to work. And it turns out this plugin does exactly what's needed in a couple of clicks: https://marketplace.atlassian.com/plugins/com.intenso.jira.plugin.dynamic-forms
I searched a bunch and never found it till someone told me about it verbally.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hopefully someone might be able to lend a hand. I have what you guys might say is an easy one but damned if I can figure it out.
I have a custom dropdown field (id 12000) with 4 options Critical, High, Medium, Low.
I have a custom free text multi line field (id 12001) that I would like to only show on the create screen when Critial is selected.
I do not have much scripting experience I came across this script listed below and then didn't know where to go. I would like to be able to just paste this into the description of the 12001 field and keep on rolling. any help would be greatly appreciated.
<script type="text/javascript">
priority = document.getElementById('priority');
if (priority) {
target = document.getElementById('customfield_10000');
// Hide the target field if priority isn't critical
if (priority.value != 2) target.style.display='none';
priority.onchange=function() {
if (this.value == 2) {
target.style.display = '';
target.value="enter message here";
} else {
target.style.display='none';
}
}
}
</script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks a lot Prasad. I have missunderstood your point. I have remove java script from custom fields description and put it into websource Java Script file and rebuild the plugins. After uploading the plugin Custom Field show/hide option works perfectly. You are amazing. Thanks a lot again.
Regards
Sumit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Glad to hear it worked!!!
if any asnwer helped then don't forget to accept as a answer/voteup so it will help other users to choose right answer!!
if any comments help then you can like those :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>> i am asking to remove javascript tags from javascript file which is included as webresource module in pugin.
Means which file ? Could you please mention the filename. Is it atlassian-plugin.xml ? Is it js file ?
Please find both the atlassian-plugin.xml and javascript.js file details -
javascript.js details -
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) { alert("JAVA!!!"); });
atlassian-plugin.xml details -
<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2"> <plugin-info> <description>${project.description}</description> <version>${project.version}</version> <vendor name="${project.organization.name}" url="${project.organization.url}" /> <param name="plugin-icon">images/pluginIcon.png</param> <param name="plugin-logo">images/pluginLogo.png</param> </plugin-info> <!-- add our i18n resource --> <!-- <resource type="i18n" name="i18n" location="javascript"/> --> <!-- add our web resources --> <web-resource key="javascript-resources" name="javascript Web Resources"> <dependency>com.atlassian.auiplugin:ajs</dependency> <!-- <resource type="download" name="javascript.css" location="/css/javascript.css"/> --> <resource type="download" name="javascript.js" location="/js/javascript.js"/> <!-- <resource type="download" name="images/" location="/images"/> --> <context>atl.general</context> </web-resource> <!-- publish our component --> <!-- <component key="myPluginComponent" class="com.atlassian.javascript.javascript.MyPluginComponentImpl" public="true"> --> <!-- <interface>com.atlassian.javascript.javascript.MyPluginComponent</interface> --> <!-- </component> --> <!-- import from the product container --> <!-- <component-import key="applicationProperties" interface="com.atlassian.sal.api.ApplicationProperties" /> --> </atlassian-plugin>
Please suggest
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have changed <context> as per your request in both the plugins and rebild again. Also I have removed <script type=
"text/javascript"
> and </script> tags from javascript file of Custom Field description. After removing
<script type=
"text/javascript"
> and </script> from Custom fileds Description the custom fields not taken this value. Entire Java script showing in its descriptionin the issue screen. Also after upload the plugins in Jira, Jira's every screen popup the plugin's ( Eg - Hello , Javascipt ) message and without clicking 'OK' I am not able to go to the next page. Which is not desired. Still "Show/Hide Custom Fields" not working
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i am asking to remove javascript tags from javascript file which is included as webresource module in pugin.
if you included jvascript as a webresource module in plugin then don't include javascript in field description
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As per your suggestion I have generate another plugin. Modified plugin's atlassian-plugin.xml file content for javascript is as follows -
<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2"> <plugin-info> <description>${project.description}</description> <version>${project.version}</version> <vendor name="${project.organization.name}" url="${project.organization.url}" /> <param name="plugin-icon">images/pluginIcon.png</param> <param name="plugin-logo">images/pluginLogo.png</param> </plugin-info> <!-- add our i18n resource --> <!-- <resource type="i18n" name="i18n" location="javascript"/> --> <!-- add our web resources --> <web-resource key="javascript-resources" name="javascript Web Resources"> <dependency>com.atlassian.auiplugin:ajs</dependency> <!-- <resource type="download" name="javascript.css" location="/css/javascript.css"/> --> <resource type="download" name="javascript.js" location="/js/javascript.js"/> <!-- <resource type="download" name="images/" location="/images"/> --> <context>javascript</context> </web-resource> <!-- publish our component --> <!-- <component key="myPluginComponent" class="com.atlassian.javascript.javascript.MyPluginComponentImpl" public="true"> --> <!-- <interface>com.atlassian.javascript.javascript.MyPluginComponent</interface> --> <!-- </component> --> <!-- import from the product container --> <!-- <component-import key="applicationProperties" interface="com.atlassian.sal.api.ApplicationProperties" /> --> </atlassian-plugin>
Previously created helloworld atlassian-plugin.xml is as follows -
<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2"> <plugin-info> <description>${project.description}</description> <version>${project.version}</version> <vendor name="${project.organization.name}" url="${project.organization.url}" /> <param name="plugin-icon">images/pluginIcon.png</param> <param name="plugin-logo">images/pluginLogo.png</param> </plugin-info> <!-- add our i18n resource --> <resource type="i18n" name="i18n" location="helloworld"/> <!-- add our web resources --> <web-resource key="helloworld-resources" name="helloworld Web Resources"> <dependency>com.atlassian.auiplugin:ajs</dependency> <resource type="download" name="helloworld.css" location="/css/helloworld.css"/> <resource type="download" name="helloworld.js" location="/js/helloworld.js"/> <resource type="download" name="images/" location="/images"/> <context>helloworld</context> </web-resource> <!-- publish our component --> <component key="myPluginComponent" class="com.atlassian.tutorial.helloworld.MyPluginComponentImpl" public="true"> <interface>com.atlassian.tutorial.helloworld.MyPluginComponent</interface> </component> <!-- import from the product container --> <component-import key="applicationProperties" interface="com.atlassian.sal.api.ApplicationProperties" /> </atlassian-plugin>
Please inform incase I have configure wrongly. After that I have build the plugin and javascript-SNAPSHOT-2.0.jar has been generated. I have upload this jar in Jira successfully. Right Now hellowworld and javascript plugin has been uploaded. But still show/hide custom field not working properly. Please suggest
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you have to use context as follows
<context>atl.general</context>
check here for valid context values
pls remove <script type=
"text/javascript"
> and </script> tags from javascript file
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My Jira UI Location is - /usr/local/apache-tomcat-6.0.14/webapps/project and Home directory is /home/secure/services/jira/project
Now I have created "atlastutorial" folder in /home/secure/services/jira/project location and build helloworld plugin. Now the atlassian-plugin.xml path is - "/home/secure/services/jira/project/atlastutorial/helloworld/src/main/resources"
But I still have not understand how does this work ? If I have add web-resources in the atlassian-plugin.xml file and add test.js under "resorces/templetes/js" does it works in our existing jira ? After creating helloworld plugin it is not showing from our existing jira http://jira.nrifintech.com. It is showing from a new URL - "http://jira.nrifintech.com:2990/jira/plugins/servlet/upm#manage". So my question is how it works in existing Jira "http://jira.nrifintech.com" ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
another easy way is add the javascript to footer.jsp(for time been)
once you add webresource on your plugin then you need to build a jar and then you need to upload it on jira
check this document, it is for beginners
https://developer.atlassian.com/display/DOCS/Set+up+the+Atlassian+Plugin+SDK+and+Build+a+Project
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Modify the above formed default atlassian-plugin.xml as <atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2"> <plugin-info> <description>${project.description}</description> <version>${project.version}</version> <vendor name="${project.organization.name}" url="${project.organization.url}" /> <param name="plugin-icon">images/pluginIcon.png</param> <param name="plugin-logo">images/pluginLogo.png</param> </plugin-info> <!-- add our web resources --> <web-resource key="helloworld-resources" name="helloworld Web Resources"> <dependency>com.atlassian.auiplugin:ajs</dependency> <resource type="download" name="yourfilename.js" location="{location of yourfilename.js}"/> <context>atl.general</context> </web-resource> </atlassian-plugin>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
At step to enter atlas-run command, you give atlas-pacakge instead. This will form a jar in yourPlugin->target
Now go to admin->ManageAddons->UploadAddon->{absolute path of your jar location}->Upload
Now check whether the script working correctly according to your requirement.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yes, with the atlas-run command, your plugin will get installed in an instance formed on logical port 2990. This means you completed how to create a plugin.
similarly follow the steps to create another plugin to fulfill your requirement.
<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2"> <plugin-info> <description>${project.description}</description> <version>${project.version}</version> <vendor name="${project.organization.name}" url="${project.organization.url}" /> <param name="plugin-icon">images/pluginIcon.png</param> <param name="plugin-logo">images/pluginLogo.png</param> </plugin-info> <!-- add our i18n resource --> <resource type="i18n" name="i18n" location="helloworld"/> <!-- add our web resources --> <web-resource key="helloworld-resources" name="helloworld Web Resources"> <dependency>com.atlassian.auiplugin:ajs</dependency> <resource type="download" name="helloworld.css" location="/css/helloworld.css"/> <resource type="download" name="helloworld.js" location="/js/helloworld.js"/> <resource type="download" name="images/" location="/images"/> <context>helloworld</context> </web-resource> <!-- publish our component --> <component key="myPluginComponent" class="com.atlassian.tutorial.helloworld.MyPluginComponentImpl" public="true"> <interface>com.atlassian.tutorial.helloworld.MyPluginComponent</interface> </component> <!-- import from the product container --> <component-import key="applicationProperties" interface="com.atlassian.sal.api.ApplicationProperties" /> </atlassian-plugin>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have not found atlassian-plugin.xml file where I have to configure webresources
Regards
Sumit Mitra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
1) you need to create a jira plugin in which you need to include web-resource.
2) I suggest you go through helloworld project that give some idea and there you find default web-resources. The following is the link
https://developer.atlassian.com/display/DOCS/Create+a+HelloWorld+Plugin+Project
3) If you already installed atlassian-sdk, you go to cmd prompt select the directory where you need this web-resource then you type atlas-create-jira-plugin
4) Then choose the jira version if ask and give some paramters as specified in above link.
5) go to the resources in yourPlugin->src->main->resources
there you find atlassian-plugin.xml
paste in prasad's code in yourPlugin->src->main->resources->js->{yourfilename.js}
in atlassian-plugin.xml you specify your web-resource as
<atlassian-plugin name="Hello World Resource" key="example.plugin.helloworld" plugins-version="2"> <plugin-info> <description>A basic web resource module test</description> <vendor name="Atlassian Software Systems" url="http://www.atlassian.com"/> <version>1.0</version> </plugin-info> <web-resource key="<somekey>" name="<somename>" > <resource type="download" name="yourfilename.js" location="{location of your filename}" /> </web-resource> </atlassian-plugin>
check if you can get or ask if you have doubt
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The following link might help you
https://developer.atlassian.com/display/JIRADEV/Web+Resource+Plugin+Module
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>> on which screen you are testing this? if it is on create screen then load javascript as webresource module in plugin, check this
I have used this settings in Create Issue screen. But from https://answers.atlassian.com/questions/47843/strange-javascript-problem-in-create-screen URL I am not understand how to load javascript as websource module in plugin. Plugin means which plugin?
In the above mentioned URL rambanam prasad has mentioned below mentioned procedure -
------------------------------------------------------------------------------------------------------------
web resource module can be add to any existing custom plugin or you can develop new one
you have to add the web resource module in atlassian-pluginn.xml and test.js should be in resorces/templetes/js
*js is a folder and it is optional
-------------------------------------------------------------------------------------------------------------
But I have not found any atlassian-pluginn.xml and resorces/templetes/js location. Also I have no experience to develop new plugin as well as no experience to add web resource module can be add to any existing custom plugin
Could you please elaborate how can we configure ?
Thanks in Advance
Sumit Mitra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
try with this 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(); }); showHidSubTaskField(); $("#customfield_10640").change(function() { showHidSubTaskField(); }); } 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(); } } function showHidSubTaskField(){ //drop down field selected value var dropDownFieldval =$.trim($("#customfield_10640 :selected").text()); //test field1 $("#customfield_10645").closest('div.field-group').hide(); if(dropDownFieldval == 'Project Audit'){ $("#customfield_10645").closest('div.field-group').show(); }if(dropDownFieldval == 'Release Audit'){ $("#customfield_10645").closest('div.field-group').show(); } } }); </script>
add this script in fied description of field configuration
and i suggest to use either javascript or behaviour plugin and test(don't use both at a time)
on which screen you are testing this? if it is on create screen then load javascript as webresource module in plugin, check this
https://answers.atlassian.com/questions/47843/strange-javascript-problem-in-create-screen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am also attaching the scrpts -
Behaviour scripts -
For Sub Audit Type
---------------------------------------------------------------------------------------------------
FormField ProductValue = getFieldById ("customfield_10625") // id for Audit Type FormField PlatformCategoryName = getFieldById ("customfield_10639").parentNode // id for Sub Audit Type String producttype = (String) ProductValue.getValue() if (producttype =~ /10800,10801/) { // id from initial part of Cascading Select "Project" PlatformCategoryName.setHidden(false) } else { PlatformCategoryName.setHidden(true) }
-------------------------------------------------------------------------------------------------------
For Sub Task
-------------------------------------------------------------------------------------------------------
FormField ProductValue = getFieldById ("customfield_10640") // id for Task Type FormField PlatformCategoryName = getFieldById ("customfield_10645").parentNode // id for Sub Task String producttype = (String) ProductValue.getValue() if (producttype =~ /10877,10878/) { // id from initial part of Cascading Select "Project Audit" PlatformCategoryName.setHidden(false) } else { PlatformCategoryName.setHidden(true) }
------------------------------------------------------------------------------------------------------
Java Srpts -
For Sub Audit Type
---------------------------------------------------------------------------------------------------
<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>
-------------------------------------------------------------------------------------------------------
For Sub Task
-------------------------------------------------------------------------------------------------------
<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_10640").change(function() { showHidField(); }); } function showHidField(){ //drop down field selected value var dropDownFieldval = $.trim($("#customfield_10640 :selected").text()); //test field1 $("#customfield_10645").closest('div.field-group').hide(); if(dropDownFieldval == 'Project Audit'){ $("#customfield_10645").closest('div.field-group').show(); }if(dropDownFieldval == 'Release Audit'){ $("#customfield_10645").closest('div.field-group').show(); } } }); </script>
--------------------------------------------------------------------------------------------------------------
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.