# In JavaScript, how can i add an event into bus group?

**URL:** https://qa.fmod.com/t/in-javascript-how-can-i-add-an-event-into-bus-group/20678
**Category:** FMOD Studio
**Tags:** javascript
**Created:** [September 20, 2023, 12:17pm UTC](https://qa.fmod.com/t/in-javascript-how-can-i-add-an-event-into-bus-group/20678 "2023-09-20T12:17:03Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Kenken0615](https://avatars.discourse-cdn.com/v4/letter/k/e36b37/32.png) [@Kenken0615](https://qa.fmod.com/u/Kenken0615)
#### Post date: [September 20, 2023, 12:17pm UTC](https://qa.fmod.com/t/in-javascript-how-can-i-add-an-event-into-bus-group/20678/1 "2023-09-20T12:17:03Z")

</div>

I have lots of events need to be moved into different buses or routing groups, but i can’t find a way to do this from Javascript.  
Please help me!!! Thank you so much!

---

<div class="post-metadata">

### Author: ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)
#### Post date: [September 21, 2023, 1:29am UTC](https://qa.fmod.com/t/in-javascript-how-can-i-add-an-event-into-bus-group/20678/2 "2023-09-21T01:29:53Z")

</div>

Hi,

Using the `.dump()` ([FMOD Studio | Scripting API Reference - ManagedRelationship.dump](https://fmod.com/docs/2.02/studio/scripting-api-reference-project-managedobject.html#managedrelationshipdump)) function on an event in the Mixer window ([FMOD Studio | Mixing - Anotomy of the Mixer](https://fmod.com/docs/2.02/studio/mixing.html#anatomy-of-the-mixer)) you can see its output is set to `output: (ManagedObject:MixerMaster)` which is what we want to change.

I have created a script which will assign a selection of events to a chosen group:

> **Example script**
>
> ```auto
> // Adding menu option
> studio.menu.addMenuItem({
> name: "Set Group",
> execute: function() {setGroup();}
> })
> 
> function setGroup() {
> var busPath = studio.system.getText("Group Path", "path");
> var bus = studio.project.lookup(busPath);
> 
> if (bus == null) {
> alert("Invalid bus path");
> return;
> }
> 
> var events = studio.window.browserSelection();
> 
> if (events.length == 0) {
> alert("Failed to find events");
> return;
> }
> 
> for (i = 0; i < events.length; i++) {
> if (events[i] == null) {
> alert("Event invalid");
> return;
> }
> else {
> events[i].output = bus;
> }
> }
> 
> alert("Assigned group");
> }
> 
> ```

hope this helps!

---

<div class="post-metadata">

### Author: ![Kenken0615](https://avatars.discourse-cdn.com/v4/letter/k/e36b37/32.png) [@Kenken0615](https://qa.fmod.com/u/Kenken0615)
#### Post date: [September 21, 2023, 2:59am UTC](https://qa.fmod.com/t/in-javascript-how-can-i-add-an-event-into-bus-group/20678/3 "2023-09-21T02:59:39Z")

</div>

Brilliant! Thank you so much!

---

<div class="post-metadata">

### Author: ![Kenken0615](https://avatars.discourse-cdn.com/v4/letter/k/e36b37/32.png) [@Kenken0615](https://qa.fmod.com/u/Kenken0615)
#### Post date: [September 21, 2023, 7:19am UTC](https://qa.fmod.com/t/in-javascript-how-can-i-add-an-event-into-bus-group/20678/4 "2023-09-21T07:19:12Z")

</div>

Sorry, it seems that this cannot work, it still stays in the previous bus, not the bus i want to assigned. When i dump an event which is assigned to a bank already, i cannot see a output property, For example:

```auto
(ManagedObject:Event):
id: "{bc929a1e-6a19-40c5-bf15-130fd12264fc}",
entity: "Event",
isValid: true,
relationships: (ManagedRelationshipMap:Event),
properties: (ManagedPropertyMap:Event),
isOfType: <function>,
isOfExactType: <function>,
nullify: <function>,
name: "BGM_Room",
isDefault: false,
note: undefined,
outputFormat: 1,
uiMarkerTracksVisible: true,
uiMaxMarkerTracksVisible: 8,
selectables: [],
folder: (ManagedObject:EventFolder),
items: [],
uiLastParameterSelection: (ManagedObject:Timeline),
mixer: (ManagedObject:EventMixer),
masterTrack: (ManagedObject:MasterTrack),
mixerInput: (ManagedObject:MixerInput),
automatableProperties: (ManagedObject:EventAutomatableProperties),
markerTracks: [(ManagedObject:MarkerTrack)],
groupTracks: [(ManagedObject:GroupTrack)],
returnTracks: [],
timeline: (ManagedObject:Timeline),
parameters: [(ManagedObject:ParameterProxy)],
tags: [],
userProperties: [],
references: [],
banks: [(ManagedObject:Bank)],
defaultEvent: null,
clonedEvents: [],
isPlaying: <function>,
isPaused: <function>,
isStopping: <function>,
isRecording: <function>,
play: <function>,
togglePause: <function>,
stopImmediate: <function>,
stopNonImmediate: <function>,
returnToStart: <function>,
keyOff: <function>,
toggleRecording: <function>,
getPath: <function>,
get3DAttributes: <function>,
set3DAttributes: <function>,
getCursorPosition: <function>,
setCursorPosition: <function>,
getPlayheadPosition: <function>,
getParameterPresets: <function>,
addGameParameter: <function>,
addGroupTrack: <function>,
addReturnTrack: <function>,
addMarkerTrack: <function>,
addTagToEvent: <function>,
getItem: <function>,
dump: <function>,
document: <function>,

```

But I found another way to achieve this! Thank you very much!!!

---

<div class="post-metadata">

### Author: ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)
#### Post date: [September 21, 2023, 11:29pm UTC](https://qa.fmod.com/t/in-javascript-how-can-i-add-an-event-into-bus-group/20678/5 "2023-09-21T23:29:42Z")

</div>

I should have mentioned you need to have the mixer window open for the script to work. Good to hear you found an alternative solution.
