I have a question related to
I'm trying to pre-populate a KCF - Autocomplete Multiple set to Issue Picker with a default issue using AJS as it is a hard constraint.
AJS.$( "#customfield_XXXX" ).select2( "val" , "" ); |
Using the call above seems to be the best approach for me. I have an issue id and am confused about the format of "" in the select2(
"val"
,
""
) portion of the call. I have a JIRA id of TST-1234
Community moderators have prevented the ability to post new answers.
Hi,
Since you want to set an issue picker (an not a default renderer), it won't be that simple. The options are not stored as strings (as in String (default) case). They are JSONs. with the next structure:
meta: { href: the url to the issue iconUrl: the icon url labelOverride: the issue key longLabel: the issue key and the issue summary shortLabel: the issue key tooltip: the issue summary } option: { label: "" value: the issue id }
In order to set your field, you should do something like this:
var temp = []; temp.push("{\"meta\":{\"longLabel\":\"TST-5 - 888\",\"tooltip\":\"888\",\"shortLabel\":\"TST-5\",\"iconUrl\":\"/secure/viewavatar?size=xsmall&avatarId=10316&avatarType=issuetype\",\"href\":\"http://localhost:7005/browse/TST-5\",\"labelOverride\":\"TST-5\"},\"option\":{\"label\":\"\",\"value\":\"10303\"}}"); AJS.$("#customfield_10700").select2("val", temp);
However, if you have JJUPIN, the most easy way to do this is by using Live Fields. All you have to do is to write a line like below, without worrying that the field is or is not a select2, or if it's an issue picker or an user picker.
lfSet("customfield_10700", "TST-5");
Hope this helps,
Alexandra
I was able to get it to work using the JSON format that you provided with one caveat.
Select2 did not alter the field but the format .val(...).change(); worked
AJS.$("#customfield_10700").val("{\"meta\":{...}}").change();
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.