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

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

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>

Hi Felipe,

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

Cheers,

Udo

However you could remove a field in the create screen.

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.

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.

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;

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

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?

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

Thanks for the quick response and sorry for the confusion

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

78 views 0 5
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