Assign From Customfield Plugin

Name Assign from Customfield Workflow Plugin
Version 1.2
Product Versions JIRA 3.4+
Author(s) Philip Herbst
Homepage  
Price free!
License BSD
JavaDocs  
IssueTracking  
Download JAR assign-from-customfield-plugin-1.3.jar
Download Source assign-from-customfield-plugin-1.3-src.zip

Assign from Customfield Workflow Plugin

This is a simple Plugin which assigns Issue to value of Customfield. Field can be of Type String or Userpicker. You can add this as a Post-Function to a transition. The field the User is pulled from is selectable via dropdown.

Code
import java.util.Map;

import org.apache.log4j.Category;

import com.atlassian.jira.ManagerFactory;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.fields.CustomField;
import com.opensymphony.module.propertyset.PropertySet;
import com.opensymphony.user.User;
import com.opensymphony.workflow.FunctionProvider;
import com.opensymphony.workflow.WorkflowException;

public class AssignFromCustomfieldFunction implements FunctionProvider
{
    private static final Category log = Category.getInstance(AssignFromCustomfieldFunction.class);

    public void execute(Map transientVars, Map args, PropertySet ps) throws WorkflowException
    {
        MutableIssue issue = (MutableIssue) transientVars.get("issue");
        String fieldId = (String) args.get("field.id");
        User assignee = null;

        assignee = getCustomfieldUser(issue, fieldId);

        if (assignee != null)
        {
            issue.setAssignee(assignee);
            issue.store();
        }
    }

    private User getCustomfieldUser(Issue issue, String fieldId)
    {
        CustomField cf = ManagerFactory.getFieldManager().getCustomField(fieldId);
        String cfType = cf.getCustomFieldType().getKey();
        User cfUserValue = null;

        try
        {
            if (cfType.equals("com.atlassian.jira.plugin.system.customfieldtypes:userpicker"))
            {
                if (cf.getValue(issue) != null)
                {
                    cfUserValue = ((User) cf.getValue(issue));
                } else if (cf.getDefaultValue(issue) != null)
                {
                    cfUserValue = (User) cf.getDefaultValue(issue);
                }
            }

        } catch (Exception e)
        {
            log.error(e);
        }
        return cfUserValue;
    }
}

Labels

 
  1. Jun 13, 2006

    Ville Jyrkkä says:

    I have tried this one. But it won't work. It won't appear to Administration > Pl...

    I have tried this one. But it won't work. It won't appear to Administration -> Plugins -view.

    Can somebody help me?

  2. Jul 04, 2006

    Yuriy Chepeliuk says:

    hi\! i also tried install this plugin to Jira 3.6#153 with modifications for 3.2...

    hi!

    i also tried install this plug-in to Jira 3.6-#153 with modifications for 3.2 but it is not working.

    We really need such plug-in.

    Thanks 

    1. Aug 18, 2006

      Philip Herbst says:

      I've updated the plugin to work with recent versions of JIRA. I have also attach...

      I've updated the plugin to work with recent versions of JIRA. I have also attached the source as a maven project. If you have problems just comment here, I'm now watching this page.

      Cheers,

      Phil 

      1. Oct 11, 2006

        Yuriy Chepeliuk says:

        Thanks a lot Philip It works (y)

        Thanks a lot Philip

        It works

  3. Oct 16, 2006

    Yair Krauze says:

    Philip, We seem to be having a problem with the plugin since I upgrade from...

    Philip,

    We seem to be having a problem with the plugin since I upgrade from 3.6.4 to 3.6.5 (at least I'm assuming the problem is related to the upgrade as we noticed it a bit after).

    We have a Task based operation called "Hand-off" where one person can hand off a task to another using a workflow screen and a custom field called "Assignee" (user picker popup). Once the user is selected and the action confirmed, we expect the Assignee to change to the selected value. This is done using your post function to assign the task based on the Assignee custom field.

    The problem is that the initial assignment does not seem to "take".  The user id value is recorded in the Change History, but it is not converted to the full user name.  Also, the task remains assigned to the original person.  A subsequent use of the action/screen seems to work whereby the assignee is recorded in the Change History as the full user name and the task is assigned to that person.  This is repeatable.

    Is it possible that some code change in 3.6.5 is affecting the initial verification of the user id in the custom field?

    Any help you can provide will be appreciated as this plugin is very useful to us.

    Regards,

    Yair

    1. Oct 16, 2006

      Yair Krauze says:

      Phil,  Onr additional point I just found out when assigning to a different ...

      Phil,

       Onr additional point I just found out - when assigning to a different person on the second assignment, the task gets assigned to the first person.

      Basically, there seems to be a "lag" of one action in assigning.

      I did verify that this is an issue only when used in an interactive workflow transition screen (where selection and assignment are done in the same operation).  We do have a couple of other screens where the next assignee is selected first into a custom field, the issue is saved, and then transitioned.  In these cases the assignment using the plugin works properly.

      Hope this helps in identifying the problem.

      Regards,

      Yair

      1. Oct 16, 2006

        Philip Herbst says:

        Hi, I hope I get you right. The problem with selection and assignment in the sa...

        Hi,

        I hope I get you right. The problem with selection and assignment in the same operation is following: The post-function is processed before the issue is stored to the database and reindexed. So the plugin operates with the old value. I've updated the plugin to check if the field is modified(on object level where the change took place) and if so it takes the modified value. [^assign-from-customfield-plugin-1.1.jar} should work for you.

        Cheers,

        Phil

        1. Oct 16, 2006

          Philip Herbst says:

          assignfromcustomfieldplugin1.1.jar
          1. Oct 16, 2006

            Yair Krauze says:

            Philip, Thank you very much, as the fix seems to work.  I'll be able to tel...

            Philip,

            Thank you very much, as the fix seems to work.  I'll be able to tell for sure when some of my team members try in tomorrow.

            Cheers,

            Yair

  4. Dec 19, 2006

    Kyle Herrmann says:

    If I understand correctly, this plugin only works with workflow transitions?&nbs...

    If I understand correctly, this plugin only works with workflow transitions?  So, I couldn't use this for auto-assigning an issue when it is created based on a customfield?  Or am I misunderstanding how this plugin works.

    1. Dec 19, 2006

      Philip Herbst says:

      Yeah, you are right. There are a few problems with what you want to achieve. Fir...

      Yeah, you are right. There are a few problems with what you want to achieve. First of all you cannot assign this workflow -post-function to the initial create action, at least from the UI. The second problem I see is that the customfield cannot have a value unless the issue exists(I guess this can be workaround by using a default value for that customfield).

      1. Dec 19, 2006

        Kyle Herrmann says:

        Thanks...I don't know how common what we want to do is, but we want something a ...

        Thanks...I don't know how common what we want to do is, but we want something a little more dynamic than components for QAing projects...and the areas that need to be QA'd may be different than the actual components within a project...not just that, we don't want people to QA "components" that aren't pertinent to the specific release. 

         
        So I was hoping to be able to use a custom field that works like components (with the auto-assigning mainly) but is either a multi-dimensional pulldown based on the version we are QAing, or a straight picker with a developer attached to each item for auto-assigning and then when a new release is to be QA'd we could remove the older custom fields so they aren't in people's faces when creating issues.  As it is now, we are creating individual projects per version, but it doesn't seem to be the most elegant solution.

        1. Dec 26, 2006

          Kyle Herrmann says:

          I managed to track down how to modify the create issue postfunctions...I'm not s...

          I managed to track down how to modify the create issue post-functions...I'm not sure based on what you said, if this plugin will still be able to do what we need, but at least I'm a little closer. 

           FYI: you can modify the create issue post-function within the workflow screen...I never really touched the New action since I mainly modified workflow transitions once an issue was created, so I just didn't think about that.

  5. May 03, 2007

    Igor (Gar) Gusarov says:

    I found a bug with version 3.8.1 of jira. In my flow when PM decides that it is...

    I found a bug with version 3.8.1 of jira.
    In my flow when PM decides that it is time to work on issue he uses trasition button. Your post-function then extracts the name of a assignee from the pre-defined custom field and should assign the issue to that person. It always worked well (with older jiras), but in 3.8.1 I encountered a strange behavior: if I fill a custom field where assignee should be taken from at the transition time (and this custom field is empty) - your plugin reads nothing and assignee is not set properly. If I fill this custom field in some way before (via Edit Issue or somehow else) - plugin works fine (actually it takes previous value for the assignee, no matter was it changed or not). Actually it is very often in my flow to fill the custom fiels at the transition moment. So could you please tell me how to both use your plugin and Jira 3.8.1?

    1. May 03, 2007

      Igor (Gar) Gusarov says:

      Oh! You've already fixed my issue. Could you please update your official plugin ...

      Oh! You've already fixed my issue.
      Could you please update your official plugin version at the top of thhttp://confluence.atlassian.com/jcaptcha/781400068?captchaId=-2123635224e page?

      1. May 03, 2007

        Philip Herbst says:

        Done\! Glad that it works for you  Cheers, Philip

        Done!

        Glad that it works for you

         Cheers,

        Philip

  6. Jul 05, 2007

    Szymon Małczak says:

    Hello, Is it realy possible to chose string type field as source fileld? That wo...

    Hello,

    Is it realy possible to chose string type field as source fileld? That would be realy usefull, as a can assing values to custom field in post function ( assignee->last developer) only if it is a string type field. 

    What I'm going for is automaticly store resolver and tester (using post functions) onece they are assigned manualy, and use your plugin to manage assignation. Hope it made some sense..

    Szymon. 

    1. Jul 05, 2007

      Philip Herbst says:

      Hi\! The current version only supports the single user picker. It would be easy ...

      Hi!

      The current version only supports the single user picker. It would be easy to add support for other fields(I've just tested it). What kind of custom field are you using? I can provide a working version shortly, if you want.

      Cheers.

      Philip

      1. Aug 22, 2007

        Maciek Gorywoda says:

        Well, for example in my opinion it would be very nice to connect your plugin wit...

        Well, for example in my opinion it would be very nice to connect your plugin with Current User Plugin, a User Picker automatically set to the current user

        1. Oct 29, 2007

          Patricia Montag says:

          would be great, getting a combination of those two plugins. is something like th...

          would be great, getting a combination of those two plugins. is something like this planned?

          1. Oct 29, 2007

            Philip Herbst says:

            Hi, I have added the Current User Plugin Field to the list of allowed fields an...

            Hi,

            I have added the Current User Plugin Field to the list of allowed fields and uploaded version 1.3 of the plugin. Hope this works for you.

            Cheers,

            Philip

      2. Jan 28

        xiangxiangme says:

        hiPhilip Herbst :  I used your plugin helpful,thanks\! but now I had a ques...

        hiPhilip Herbst :

         I used your plugin helpful,thanks! but now I had a question : it can't support the multi user piker,how i can supprot the multi user piker of custom field?

  7. Jul 06, 2007

    Szymon Małczak says:

    Hello, I'm using 'Text Field (< 255 characters)'.&nbsp; It would be great, thank...

    Hello,

    I'm using 'Text Field (< 255 characters)'.  It would be great, thank you;]

    Szymon.

    1. Jul 06, 2007

      Philip Herbst says:

      Hi, I hope this will suit your needs\! assignfromcustomfieldplugin1.2.jar Che...

      Hi,

      I hope this will suit your needs! assign-from-customfield-plugin-1.2.jar

      Cheers,
      Phil

  8. Aug 17, 2007

    naveen.ks says:

    Hi Phil, \\ am unable download assignfromcustomfieldplugin1.2.jar \\ could you p...

    Hi Phil,

    am unable download assign-from-customfield-plugin-1.2.jar

    could you plaese check this URL

    thanks

    NAVEEN ks

  9. Aug 17, 2007

    naveen.ks says:

    Hi Phil,\\ plaese send us sorce files as well\\ Thanks Naveen Ks\\

    Hi Phil,

    plaese send us sorce files as well

    Thanks

    Naveen Ks

  10. Sep 30, 2007

    Soukup Marek says:

    Hi Phil, i created user picker custom field and then i added post function assig...

    Hi Phil,

    i created user picker custom field and then i added post function assign from custom field to my workflow. I deleted the custom field by mistake. Post function was still in the workflow so I deleted it manually by editting the xml file. The problem is I've had the name of deleted custom field in the list of possible values when i've tried to create new assign from custom field post function.

     Can you help me to solve this problem out? How to remove the custom field name from the list?

    Thank you for your help

    Marek Soukup 

    1. Oct 15, 2007

      Philip Herbst says:

      Hi Marek, Sorry for late reply. Does the problem persist? Which version of the p...

      Hi Marek,

      Sorry for late reply. Does the problem persist? Which version of the plugin and of Jira are you using? I remember a similar problem which existed in earlier versions, but cannot reproduce it with the current version.

      Cheers,

      Philip 

  11. Oct 16, 2007

    Tyler Theobald says:

    Philip, Using JIRA 3.11..... I am trying to use this plugin (1.2) for the first ...

    Philip,

    Using JIRA 3.11..... I am trying to use this plugin (1.2) for the first time, but don't see it showing up in my list of plugins and don't see any options in the post functions tab of a transition.  What else should I check?

    1. Oct 17, 2007

      Tyler Theobald says:

      Philip, OK, so I found the option under postfunctions, but what is the name of t...

      Philip, OK, so I found the option under post-functions, but what is the name of the plug-in on my Current Plugins screen?

      1. Oct 17, 2007

        Philip Herbst says:

        Hi Tyler, I forgot to set a proper name for the plugin. It is listed under {}Wor...

        Hi Tyler,

        I forgot to set a proper name for the plugin. It is listed under Workflow Plugin (that with just 1 module). It's unfortunate that there is a Jira built-in plugin with the same name (with more modules).

        Sorry for the hassle,

        Philip

  12. Dec 10, 2007

    Edwin Cettinich says:

    Hi, this plugin works really well on 3.11, but as Philip said it does not work o...

    Hi,
    this plugin works really well on 3.11, but as Philip said it does not work on the initial create-transition.

    I would like to let the reporter assign the issue initially via a user picker customfield (I want to give him the opportunity to filter the assignable list by groups). Does anyone have an idea how to get such a functionality?

    Thanks a lot in advance,

    Edwin 

    1. Feb 15

      Joel Tecson says:

      Hi, I think this plugin will help.

      Hi,

      I think this plugin will help.

      http://forums.atlassian.com/thread.jspa?threadID=18494

      but the problem is, I dont see the pre configured custom Field in the choices for parameters in the function.

      if you found out why please let me know. It will be highly appreciated.

      Thanks....

      1. Feb 19

        Edwin Cettinich says:

        Hi Joel, this plugin is working really well on the inital create transition. The...

        Hi Joel,

        this plugin is working really well on the inital create transition. The main thing was to put this post function before (!) the "store" function and after (!) the "create this issue initially" function.

         I don't know the plugin you are referencing to. Maybe you can't see the custom field because of missing permissions.

        Cheers,

        Edwin

  13. Jan 28

    xiangxiangme says:

    hiPhilip Herbst : &nbsp;I used your plugin helpful,thanks\! but now I had a ques...

    hiPhilip Herbst :

     I used your plugin helpful,thanks! but now I had a question : it can't support the multi user piker,how i can supprot the multi user piker of custom field?

  14. Feb 13

    Simona Necula says:

    Hi,\\ I downloaded the jar and added it to my jira WEBINF/lib and I bounced the ...

    Hi,

    I downloaded the jar and added it to my jira WEB-INF/lib and I bounced the server.

     I cannot see the new plugin on the list of available plugins.

    Please advise. Thanks.

    1. Feb 13

      Simona Necula says:

      I found it and it works. It just had the same label "Workflow Plugin" as another...

      I found it and it works. It just had the same label "Workflow Plugin" as another plugin.

       Simona

  15. Feb 14

    Joel Tecson says:

    Hi, Im in a process of evaluating JIRA 3.11 and I think this plugin is nice. Is ...

    Hi,

    Im in a process of evaluating JIRA 3.11 and I think this plugin is nice. Is there a posibility that this plugin will be integrated with the pre configured userpicker plugin?

    http://forums.atlassian.com/thread.jspa?threadID=18494

    Please help me in this... I dont have enough knowledge in programming jsp.

    Hoping for your quick response....

    Thank you very much

  16. May 12

    Miji Mathews says:

    Can I use this plugin with the "Cascading Select" type field. thanks&n...

    Can I use this plugin with the "Cascading Select" type field.

    thanks