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.
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<Group>)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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Could you help me to resolve the above issue.
Any updates on this issue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can do this by putting small java script in the single selection field.
Here are some references:
https://answers.atlassian.com/questions/212962/javascript-in-jira-set-values-to-fields-according-value-specified-in-a-listbox
https://confluence.atlassian.com/display/JIRA/Displaying+a+Field+Based+on+Another+Field+Selection
Hope this helps.
Vijay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vijay,
Many thanks for your support, Please let me know when you get any positive output.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes Vijay I did in the same place, But I found the above issue. Could you please help me!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.