On the selection of dropdown value how to change the assignee

I want to change the name of the assignee on the selection of the Region dropdown value.

How can I achieve this, Please share the code for the same.

2 answers

Hi Vijay,

I want to change the name of Assignee on the selection of custom field value.

for eg:

If the custom field selected value is "1" then Assignee name should be "abc", If the custom field selected value is "2" then Assignee name should be "pqr", if the custom field selected value is "3" then Assignee name should be "xyz" and etc...

Is this possible to change the name of the Assignee on the selection of dropdown value?

Please do the needful.

Regards

Hi Najmul,

I havent done this myself yet so cant say the articles I posted helps you directly. They are more specific requests and you have to modifiy accoding to your needs.

I can try it for you once I have time. I will get back if I get it to work.

Vijay

Hi Vijay,

Many thanks for your support, Please let me know when you get any positive output.

Regards

Hi,

This is working for me

<script type="text/javascript">
  source = document.getElementById('customfield_13750');
  if (source) {
      target = document.getElementById('assignee');
      // Hide the target field if priority isn't critical
      source.onchange=function() {
          if (this.value == <selection option id>) {
                     target.value='assignee_user_name';
                  }
      }
  }
 </script>

You need to change the customfield ID and the assignee name. Also make sure the <selection_option_id> is the id of the option of the customfield and not the option itself. It is a 5 digit number normally.

Vijay

Thanks Vijay,

I am using your code and working fine but the value is not going to be set into the Assignee field. I tried multiple time with the help of alert.

And found every line is executing properly upto the end. The target.value getting the value also but the value is not coming in the Assignee field on the UI.

Could you please help me to come out form this.

Hi Najmul,

You have to put the code in the description field of the customfield. Go to Administration -> Addons -> Custom Fields -> Find your customfield -> Edit and put the script in description of the field.

Here is the doc link.

https://confluence.atlassian.com/display/JIRA/Configuring+a+Custom+Field#ConfiguringaCustomField-editEditingacustomfield

This makes it global for all the projects that use the custom field. If you want to do specific to one project, you need to edit it in the field configuration scheme for that project. Doc link below.

https://confluence.atlassian.com/display/JIRA/Specifying+Field+Behavior#SpecifyingFieldBehavior-Editingafieldconfiguration

Vijay

Yes Vijay I did in the same place, But I found the above issue. Could you please help me!

If you are doing this at issue creation and before submitting if you want to change value then I guess java script - before performing any event or issue update.

If you want to happen this on issue created, updated event then groovy script do where it will actually change the asignee and email notification will flot

e.g.

import com.opensymphony.workflow.WorkflowContext
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.event.issue.AbstractIssueEventListener
import com.atlassian.jira.event.issue.IssueEvent
import org.apache.log4j.Logger
import static org.apache.log4j.Level.DEBUG
import com.atlassian.jira.bc.issue.IssueService.UpdateValidationResult
import com.atlassian.jira.bc.issue.IssueService.IssueResult
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.bc.issue.IssueService.TransitionValidationResult
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.util.ErrorCollection
import com.atlassian.jira.issue.index.IssueIndexManager

class invoketransition extends AbstractIssueEventListener {
        Logger log = Logger.getLogger(invoketransition.class)
        @Override
        void issueUpdated (IssueEvent event) {
                log.setLevel(org.apache.log4j.Level.DEBUG)
                def field = event.getChangeLog().getRelated('ChildChangeItem').any{ it.field.toString().equalsIgnoreCase("YourFieldName")}
                if (field){
                	def cfg = customFieldManager.getCustomFieldObjects(issue).find {it.name == "YourFieldName"}
                        def cfgvalue =(List&lt;Group&gt;)issue.getCustomFieldValue(cfg)
                        if (cfgvalue == "1")
                        	//set issue.assignee = "abc"
                        //else if and so on
                }
       }
}

Hi Paresh,

Thanks for your help,

The code provided by you is not worked in my case I tried several time but nothing seems to be worked.

Could you please share some code that I can write in the Behaviour, So that while filling the field user can see the update what is going on.

Plesse do the needful

Regards

Hi,

Could you help me to resolve the above issue.

Any updates on this issue

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 yesterday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

309 views 4 9
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