Setting autocomplete-multiuser field using Javascript/JQuery

We have a blueprint wizard that selects appropriate templates and fills in a bunch of values depending on what the user selects. We have one page that’s got an autocomplete-multiuser field.

We now have the need, in some cases, to pre-fill this and select a user or two as a suggestion for the user. I can’t for the life of me work out how to do this.

As the field is a Select2 under the hood - I thought it would be as simple as:


However, it is not. Any ideas? Any help would be much appreciated!

It matters how your field is set up, doesn’t it? Is this remote data (<input />) or is this local data (<select><option></option></select>)?

Well, it’s Atlassian’s autocomplete-multiuser field. The setup was:
Field in soy template:

<input id="fooID" type="text" class="autocomplete-multiuser" data-none-message="No users found" data-template="{literal}{username}{/literal}" name="fooName">

And then in .js:


When beginning to type, I believe the field searches for matching users in our Confluence/JIRA. When the users are selected in the field itself - they’re just the user’s email addresses so I assumed that setting the field value to a user’s email address may display the user in the field. However, it does not.