Can I add condition to the "create issue" action in Jira Behaviour?

Felipe Reis
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.
September 5, 2013

Hi!

I want to add the following behaviour to a workflow:

- Hide a field when user is in a certain group AND when issue is being created.

The first condition was quite simple to include. However I'm having troubles with the latter.

I have chosen a guide workflow which has the "create" action (I believe every workflow in Jira has this action), but this action does not appear in the Workflow Action list box.

Any tips?

Cheers!!!

4 answers

1 accepted

1 vote
Answer accepted
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.
September 9, 2013

You have to write code to do it rather than choose options from the web UI.

You would use:

getActionName() == "Create" && <your code to see if the current user is in group X>

0 votes
Martin Spielmann March 22, 2016

is there a chance to get this as a feature in a future version of JIRA?

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.
March 22, 2016

Do you mean a future version of the plugin? If so you are able to do that now... maybe I'm missing something, or perhaps your answer doesn't relate to the question?

Martin Spielmann March 22, 2016

Argh, I'm sorry. I was posting in the wrong tab.

Thanks for the quick response and sorry for the confusion

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.
September 5, 2013

you can hide field for specific group by using following javascript, i suggest to add it as webresource in a plugin

&lt;script type="text/javascript"&gt;  
jQuery(document).ready(function($) {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
hideField();    
})
hideField();
function hideField(){
var issueTypeCreate =document.getElementById('issuetype-field'); 
var issueType =$('#issue-create-issue-type').text();
if((document.getElementById('customfield_10571') != null  || (issueTypeCreate!=null &amp;&amp; issueTypeCreate.value == "Defect") || issueType == "SVN Kit"){
        var user=getCurrentUserName();			
		if(isUserInGroup(user,'Developers') ){
			//to hide field
			$("#customfield_10571").closest('div.field-group').hide();
		}else  {
		/to show field
			AJS.$("#customfield_10571").closest('div.field-group').show();
		}

}
}
function getCurrentUserName()
{
var user;
     AJS.$.ajax({
        url: "/rest/gadget/1.0/currentUser",
        type: 'get',
        dataType: 'json',
        async: false,
        success: function(data) {
            user = data.username;
        }
     });
     return user;
}
  
  
function getGroups(user)
{
var groups;
     AJS.$.ajax({
        url: "/rest/api/2/user?username="+user+"&amp;expand=groups",
        type: 'get',
        dataType: 'json',
        async: false,
        success: function(data) {
            groups = data.groups.items;
        }
     });
     return groups;
}
function isUserInGroup(user, group){
    var groups = getGroups(user);
    for (i = 0; i &lt; groups.length; i++){
         if (groups[i].name == group){
              return true;
         }
    }
    return false;
} 
 
});
&lt;/script&gt;

0 votes
Udo Brand
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.
September 5, 2013

Hi Felipe,

you can't add a condition to the create transition. There are only validators and post functions possible.

Cheers,

Udo

Udo Brand
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.
September 5, 2013

However you could remove a field in the create screen.

Felipe Reis
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.
September 5, 2013

Thank you for your answer Udo!

However you did not read my question carefully enough.

My question is related to the Jira Behaviour Plugin. So the condition I've mentioned is not a Workflow condition.

I could remove the field from the create screen, however I would like this field to appear on the screen if the users are not in a certain role.

Udo Brand
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.
September 5, 2013

Well, your question is quite ambiguous since your talking about 'create' and Workflow action as well as 'add the behavior to a workflow'.

However, maybe Ramabanams answer fit your need.

Good luck.

Suggest an answer

Log in or Sign up to answer