# How to find referenced event relationship

**URL:** <https://qa.fmod.com/t/how-to-find-referenced-event-relationship/20708>\
**Category:** FMOD Studio\
**Tags:** javascript\
**Created:** [September 27, 2023, 10:49am UTC](https://qa.fmod.com/t/how-to-find-referenced-event-relationship/20708 "2023-09-27T10:49:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MisakaCirno](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@MisakaCirno](https://qa.fmod.com/u/MisakaCirno)\
**Post date:** [September 27, 2023, 10:49am UTC](https://qa.fmod.com/t/how-to-find-referenced-event-relationship/20708/1 "2023-09-27T10:49:28Z")

</div>

I am trying to get the dependencies between Banks and export them. But first I need to get the references between Events.

I used `studio.project.model.Event.findInstances()` to get all the Events. and then found out that there are reference relationships that get stored in `ManagedObject:Event.references`. But the object type in there is `ManagedObject:EventSound`, not `ManagedObject:Event`.

`ManagedObject:EventSound` doesn’t seem to include any information about the Event itself.

How do I get the relationship between Events?

* * *

Also, is getting the association between them and manually loading the `.bank` file where the referenced Event is located the best way to handle this?

Does FMOD already have a way to find the Bank it depends on and load it?

---

<div class="post-metadata">

**Author:** ![MisakaCirno](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@MisakaCirno](https://qa.fmod.com/u/MisakaCirno)\
**Post date:** [September 27, 2023, 10:58am UTC](https://qa.fmod.com/t/how-to-find-referenced-event-relationship/20708/2 "2023-09-27T10:58:53Z")

</div>

Well, once again, I’m missing key information.  
The `ManagedObject:EventSound` object has an `event` member, which stores the Event itself.

So now only the second question remains.

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [September 28, 2023, 1:03am UTC](https://qa.fmod.com/t/how-to-find-referenced-event-relationship/20708/3 "2023-09-28T01:03:48Z")

</div>

> [@MisakaCirno](#):
>
> Also, is getting the association between them and manually loading the `.bank` file where the referenced Event is located the best way to handle this?
> 
> Does FMOD already have a way to find the Bank it depends on and load it?

I’m not sure if this is exactly what you’re getting at, but by default building your banks in FMOD Studio will automatically include referenced events. You can disable this for your Studio Project in Preferences → Build. For more information, I would recommend reading over the Studio documentation on [Including Referenced Events in Banks](https://fmod.com/docs/2.02/studio/getting-events-into-your-game.html#including-referenced-events-in-banks), and the API documentation on [Bank Loading](https://fmod.com/docs/2.02/api/studio-guide.html#bank-loading)

---

<div class="post-metadata">

**Author:** ![MisakaCirno](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@MisakaCirno](https://qa.fmod.com/u/MisakaCirno)\
**Post date:** [September 28, 2023, 2:29am UTC](https://qa.fmod.com/t/how-to-find-referenced-event-relationship/20708/4 "2023-09-28T02:29:14Z")

</div>

Yes, I have been informed of this. But this means that if an Event is referenced by an Event in more than one Bank file, it will be copied multiple times to each Bank, resulting in a larger `.bank` file.

I refer to the documentation and in this case it is recommended to put the referenced Event in a separate Bank file.

But then the dependencies between the Events should have to be documented.

---

<div class="post-metadata">

**Author:** ![MisakaCirno](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@MisakaCirno](https://qa.fmod.com/u/MisakaCirno)\
**Post date:** [September 28, 2023, 9:37am UTC](https://qa.fmod.com/t/how-to-find-referenced-event-relationship/20708/5 "2023-09-28T09:37:45Z")

</div>

I realized I missed a detail.

`ManagedObject:EventSound.event` gets the name of the referenced Event itself, not the name of the referrer, although it does add members as the number of references increases, which didn’t solve my problem.

I found that when selecting an Event, choosing **Find References … - In Events** in the context menu it is possible to get the list of references.

What should be the correct way to get it?

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [October 4, 2023, 3:47am UTC](https://qa.fmod.com/t/how-to-find-referenced-event-relationship/20708/6 "2023-10-04T03:47:15Z")

</div>

I believe the simplest way of retrieving all Event referencing a given Event `referencedEvent` is to get the `audioTrack` that the Event Instrument playing `referencedEvent` is on, and get the referencing `event` from there. For example:

```js
//iterate over all references
referencedEvent.references.forEach(function(event){
	event.audioTrack.event //the referencing event
})

```

This should work regardless of the type of sheet the Event Instrument is on.
