Can I restrict assignee selection to members of a group picker custom field?

Hi 

I am trying to create a notification scheme that will send a notification to one of five "tech approver" groups created in JIRA, when the ticket reaches a certain part of the workflow (ie "awaiting tech approval").

I have created a post-function on the transition to the "awaiting tech approval" stage. The post-function fires an event, which in turn notifies the group specified in a custom field group picker in the ticket.

The problem is that when entering the group in the field, you can see ALL of JIRA's groups. Which is a lot more than five.

Is there a way of limiting the number of groups?

Alternatively, I would like to create a dropdown custom field picker, where the user selects an "area" that is mapped to the appropriate group. (ie picking "Enterprise" in the field would then result in a post-function mapping Enterprise to "tech-notify-enterprise"). Is there any way of doing this?

Thanks for your time.

1 answer

1 accepted

This widget could not be displayed.
Micky Caritte Community Champion Nov 29, 2017

Hi Adam,

My suggestion would be to edit your permission scheme and grant the "Assignable User" permission to a group custom field value as described below:cfAssignee.png

That would only allow users from the group in the custom field to be assignee. Please note that this will apply to the whole project and you'll need to carefully prefill this custom field with the relevant group at all time! The custom field value could be easily changed from a status to another using post functions.

Would that work?

Thanks

Thanks very much Mickey. I don't think that would work for us because we still require the ticket to be assigned to someone else, we're just looking to notify one of a few groups. However, that is a really interesting feature and one I might use in future!

Best wishes and Merry Christmas

Adam

Micky Caritte Community Champion Jan 04, 2018

Hi Adam,

Thanks for your feedback and sorry for my delayed response!

You have a happy new year and best luck with Jira :)

Thanks you too Micky.

In the end this was the solution I devised with the help of a colleague and the community. 

  1. I have the group picker, which is a single group custom field, which cannot be edited (by omitting it from the create/edit screen). I call this field "Technical Approvers Groups"
  2. I have a second custom field, which is a single choice, drop-down select list. This is a mandatory field on the create/edit screen. I call this "Change Area".
  3. I have a custom scripted field that is made using Scriptrunner. I use this to map the value from the select list in step 2, to the group picker in step 1. This custom field is hidden from view and works in the background. It is only applied to the project for which I'm using it. It uses the following script.
    import com.atlassian.jira.component.ComponentAccessor;
    import com.atlassian.jira.issue.CustomFieldManager;
    import com.atlassian.jira.issue.Issue;
    import com.atlassian.jira.issue.fields.CustomField;
    import com.atlassian.jira.issue.MutableIssue;
    import com.atlassian.jira.issue.ModifiedValue;
    import com.atlassian.jira.issue.util.DefaultIssueChangeHolder;

    MutableIssue issueToUpdate = (MutableIssue) issue;

    // create the map of Change Area names to approval groups
    def approvalGroupMap = [
    "TA Group 1" : "tech-approval-group1",
    "TA Group 2" : "tech-approval-group2",
    "TA Group 3" : "tech-approval-group3",
    "TA Group 4" : "tech-approval-group4",
    "TA Group 5" : "tech-approval-group5"
    ];

    // get the value of the "Change Area" field
    def changeAreaFieldObject = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_XXXXX");
    def changeArea = issue.getCustomFieldValue(changeAreaFieldObject).toString();

    //configure and define the value taken from the "Change Area" field as a group, rather than a simple string (this is necessary)
    def customFieldManager = ComponentAccessor.getCustomFieldManager()
    def groupManager = ComponentAccessor.getGroupManager()
    def group = groupManager.getGroup(approvalGroupMap[changeArea])

    //taking the group value defined immediately above, use it to set Techical Approvers Group field
    def tgtField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjects(issue).find {it.name == "Technical Approvers Groups"}
    def changeHolder = new DefaultIssueChangeHolder();
    def mv = new ModifiedValue(issue.getCustomFieldValue(tgtField), [group]);
    tgtField.updateValue(null, issue, mv,changeHolder);

    //test with a return group to make sure it is working.
    return group

    What all this allows me to do is have a user-friendly and limited choice custom field, with option names I can control and which are mapped on the back end to specific JIRA groups.

  4. I have a custom notification, which alerts the group mapped in the custom field Technical Approvers Groups. 
  5. Finally I set up a post-action on a transition (called Submit for Review) that fires the notification out to the appropriate approver group.

Hope this helps anyone thinking about doing something similar!

Best wishes

Adam

Micky Caritte Community Champion Jan 05, 2018

Great, interesting! Thanks for sharing!

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted yesterday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

79 views 0 1
Join discussion

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