Hello!
I would like to know, is it possible to change assignee via javascript?
I don't want to use post-function, because user would like to see who is going to be assigned and change if he wants.
We are in migrate process from 4.4 to 5.0, but I suppose, that AssigneePicker has not been refatored too much.
And yes, I've searched 'answers' before posting this :]
Thanks in advance!
Community moderators have prevented the ability to post new answers.
var loggedInUser = JIRA.Meta.getLoggedInUser(); var assigneeSelect = $("#assignee", context); assigneeSelect.trigger('set-selection-value', loggedInUser.name);
This is the most correct way to set assignee.
Hi, when I try this, I get an error regarding the context. I found a workaround for this by:
var assigneeSelect = document.getElementById('assignee');
After this change, I get an error regarding the trigger function which it says is not known. I use JIRA 5.2.8.
Does anyone know what I can do to set a user-id/name to the assignee in a popup resolve screen from a custom field (Responsible)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you trying to set assignee on the issue creation page based on some condition ?
I dont have a javascript solution but may i think behaviours plugin can help ,
You can add a behaviour to the assignee field , check for the condition and accordingly set the assignee .
You can refer these documentations
https://studio.plugins.atlassian.com/wiki/display/JBHV/Miscellaneous+Behaviours+Examples
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for answer!
but the problem is that JIRA.AssigneePicker is created using some javascript magic (I suppose via prototype inheritance). So it's not as easy as
AJS.$("#assignee-field").val("foobar")
There is some model, some descriptor and so on. I tryed to get some info via Firebug
JIRA.AssigneePicker.prototype.getDisplayVal()
but have an error
TypeError: this.options is undefined [Break On This Error] return descriptor[this.options.itemAttrDisplayed || "label"]();
So, your method doen't work for assignee filed :(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am able to get and change the assignee using the following script
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")
Hope you find it useful
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Okay, it's better now, but still doen't work.
I've got "Issues must be assigned." error (even if I only change 'summary' for example)
I've created user test1 and add him to jira-developers. I'm able to assign issues. Now I added new behaviour for assignee filed. When I create or edit any issue I've got such an error.
In log I see previous assigned user or 1 when creating issue.
I'm on Jira 5.0.4
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So, at the end of the day my collegue fond solution:
var value = "test1"; AJS.$("#assignee-field").val(value); AJS.$("#assignee").find(":selected").data("descriptor").model()[0].value = value;
This code will change value in edit box, which is visible and set option in hided select list. After posting data to server you will get right that value!
One drawback of this solution, that is doesn't handles users's avatar. We don't need this, but if you do - just make ajax call to http://docs.atlassian.com/jira/REST/latest/#id164624 and parse response.
I hope, someone will find this solution helpfull. Also, this should work ok for every user picker (assignee, reporter or any custom field).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Does not work for me!!
Here is my code: I want to copy user in customfield_11320 to customfield_11124.
<script type="text/javascript">
AJS.$(document).ready(function() {
var value = AJS.$("#customfield_11320").val();
AJS.$("#customfield_11124").val(value);
});
</script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Grigory, where did you put this code:
var value = "test1"; AJS.$("#assignee-field").val(value); AJS.$("#assignee").find(":selected").data("descriptor").model()[0].value = value;
I need to do something similar, I'm using the bahaviours plugin to set a value to the assignee field depending of other field, but I can't get that working, so, where did you put your code to get it work? thanks
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.