Hi,
my current customer is by far not happy the way JIRA handles the assignee field. So I'm hoping one of you can help me out...
1. Has anyone achieved to get rid of the "automatic" pre-poplulation of the assignee field? Iwould need it to be either empty or prepopulated with the current user. I've achieved prepopulating a custom user picker with the current user but adapting this script (behaviours plugin) to the assignee field won't work . Using a post-function won't work either since the user should be offered the possibility to select another assignee upon issue creation.
That was my script:
import com.atlassian.jira.ComponentManager FormField formAG = getFieldByName("Auftraggeber") currUser = ComponentManager.getInstance().getJiraAuthenticationContext().getUser() currUserName = currUser.getName() if(!formAG.getFormValue()){ formAG.setFormValue(currUserName) }
2.Is there anyway to get rid of the assign to me link right next to the field on my screen? I don't see any ponit in removing this feature, but anyway my customer wants this to be evaluated... Deactivation the issue operation "Assign to me" doesn't do the trick.
The first question is by far more important to me... (and my customer). Any ideas are being appreciated.
Cristian, can't get your point. I've checked my code in firebug - works fine.
There is no console.log in my code. Could you explaint, what's the problem?
Hey Grigory,
no problem so far. I'm just trying to use your code using Behaviours Plugin. I'm not a Javascript expert so it takes some time for me to figure out what your code is doing and to edit it in order to just setting the assignee to current user. The "assign to me blocking works just fine":-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah, that's what the problem! My code is supposed to use as is - without Behaviours Plugin. Just paste it in field's description, as described here.
hope, it helped.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've also tested the other script you mentioned in your post
var value = "test1"; AJS.$("#assignee-field").val(value); AJS.$("#assignee").find(":selected").data("descriptor").model()[0].value = value;
When I change the first line to "value = JIRA.Meta.getLoggedInUser();" I get an output like this: [object Object]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I've tried a code you provided in another post:
https://answers.atlassian.com/questions/59501/change-assignee-via-javascript
That's how my description field looks like:
<script type="text/javascript"> var loggedInUser = JIRA.Meta.getLoggedInUser(); var assigneeSelect = $("#assignee", context); assigneeSelect.trigger('set-selection-value', loggedInUser.name); </script>
No effect. What am I doing wrong?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh, there were some bugs in script. Here is one that works for me:
<script type="text/javascript"> var loggedInUser = JIRA.Meta.getLoggedInUser(); var assigneeSelect = AJS.$("#assignee"); assigneeSelect.trigger('set-selection-value', loggedInUser.name); </script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Grigory, that one works!!! Thank you so much. Just ONE last question :-)
Applying this script to the description field changes the assignee to the LoggedInUser every time I edit the issue, right?
I only wnat this to happen upon issue creation. Is there a way to achieve this like:
... if(assigneeSelect = "Automatic") ....?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here you go:
<script type="text/javascript"> if (AJS.$("#assignee").val()[0] === "-1"){ var loggedInUser = JIRA.Meta.getLoggedInUser(); var assigneeSelect = AJS.$("#assignee"); assigneeSelect.trigger('set-selection-value', loggedInUser.name); } </script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Brilliant, thank you so much for your time!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Can you please explain me More?
Where this code should be set in Jira?
Regards
JLuis
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello!
We've encountered a similar problem - change assignee, depending on other field. So, here is piece of javascript we use to change assignee:
function changeAssignee(value){ var assignee = AJS.$("#assignee"); var model = new AJS.SelectModel({ element: '#assignee', removeOnUnSelect: false }); JIRA.SmartAjax.makeRequest({ url: "/rest/api/2/user", data: {username: value}, complete: function (xhr, status, response) { if (response.successful){ var descriptor = new AJS.ItemDescriptor( { value: response.data.name, fieldText: response.data.displayName, label: response.data.displayName, //+ ' - ' + response.data.emailAddress + ' (' + response.data.name + ')', allowDuplicate: false, icon: response.data.avatarUrls['16x16'] }); model.setSelected(descriptor); assignee.trigger('set-selection-value', value); } } }); }
You can put this with minor modifications in fields description to make it run each time automatically.
To get current user via javascript you use this:
var loggedInUser = JIRA.Meta.getLoggedInUser();
To get rid of Assign to me use this:
AJS.$("#assign-to-me-trigger").hide()
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.
Grigory, a question related to this:
I want to clear the Reporter field (so there is no prepopulated default value) on the create issue screen using Javascript in the field configuration (field description). Any idea how I would do that? I can't figure it out. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Christian,
I just came accross exactly the same issues. I want to accomplish these two exact things:
1) getting rid of the automatic value for the assignee field (instead setting it to current user)
2) getting rid of the assign to me link next to the field.
I am new to JIRA and I installed 6.2.2, which it seems it has a lot of incompatibilities (for instance there is not behavious plugin for JIRA 6.2.2 yet).
Can you help me how to accomplish those two things?
Thank you in advance
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found another solution:
I combined the behaviour-plugin with javascipt and that's the only solution that works for me with JIRA v.5.1.2 to set the assignee depending on antoher field:
Here is the Behaviour-code:
FormField FieldAssignee = getFieldById("assignee") // Feld Bearbeiter
FormField FieldLeistungsklasse = getFieldById ("customfield_10503")
switch (FieldLeistungsklasse.getValue()) {
case null :
FieldLeistungsklasse.setHelpText("<script type=\"text/javascript\">var value=\"cas_admin\";\
AJS.\$(\"#assignee-field\").val(value);\
AJS.\$(\"#assignee\").find(\":selected\").data(\"descriptor\").model()[0].value=value;</script>")
break
case "XS" :
FieldLeistungsklasse.setHelpText("<script type=\"text/javascript\">var value=\"ariu001\";\
AJS.\$(\"#assignee-field\").val(value);\
AJS.\$(\"#assignee\").find(\":selected\").data(\"descriptor\").model()[0].value=value;</script>")
break
case "S" :
FieldLeistungsklasse.setHelpText("<script type=\"text/javascript\">var value=\"hube009\";\
AJS.\$(\"#assignee-field\").val(value);\
AJS.\$(\"#assignee\").find(\":selected\").data(\"descriptor\").model()[0].value=value;</script>")
break
case "M" :
FieldLeistungsklasse.setHelpText("<script type=\"text/javascript\">var value=\"winte02\";\
AJS.\$(\"#assignee-field\").val(value);\
AJS.\$(\"#assignee\").find(\":selected\").data(\"descriptor\").model()[0].value=value;</script>")
break
case "L" :
FieldLeistungsklasse.setHelpText("<script type=\"text/javascript\">var value=\"scill02\";\
AJS.\$(\"#assignee-field\").val(value);\
AJS.\$(\"#assignee\").find(\":selected\").data(\"descriptor\").model()[0].value=value;</script>")
break
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you are using Behaviours plugin try the below code
import com.onresolve.jira.groovy.user.FieldBehaviours import com.onresolve.jira.groovy.user.FormField FormField assignee = getFieldById(fieldChanged) Object componentFormValue = assignee.getFormValue() log.debug("-------------------assignee---"+componentFormValue) if(componentFormValue=="Automatic"){ assignee.setFormValue(ComponentManager.getInstance().getJiraAuthenticationContext().getUser().getName()) }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is a system plugin "Issue Operations plugin" in that ther is a module "
View Issue Ops Bar Assign To Me Link" you will have to disable this to get rid of the asssign to me link .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey, that's not what I wanted. I just wanted to deactivate it on the screen. Worked with Grigory's promt...
So far I don't get the code you provided working. In the log I just see ("-------------------assignee---"1
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ok , replace the if condition with the below line
if
(componentFormValue==
"1"
){
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Mizan,
won't work. I also tried a code you posted in:
https://answers.atlassian.com/questions/59501/change-assignee-via-javascript
import com.onresolve.jira.groovy.user.FieldBehaviours import com.onresolve.jira.groovy.user.FormField FormField assignee = getFieldById(fieldChanged) Object componentFormValue = assignee.getFormValue() log.debug("-------------------assignee---"+componentFormValue) assignee.setFormValue("test1")
No "if clause" and still no changes...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
do you have test1 as a user ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes I do . Any ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is that user an assignable user ? do you see the user in the asignee field dropdown ?
I have done this and it should work. check if you are have any typo ;)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Really strange. User is assignable and I copied the script from above so I guess no typos this time:-) The solution Grigory provided does work so I go with that right now even though I'd prefer using behaviours plugin since all my other rules are being set there...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
actually the script triggers when you change the value of some other field and the behaviour should be applied to that field .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.