# JS Scripting API: checking if event has a multi-instrument

**URL:** <https://qa.fmod.com/t/js-scripting-api-checking-if-event-has-a-multi-instrument/23506>\
**Category:** FMOD Studio\
**Tags:** studio-scripting-api\
**Created:** [October 23, 2025, 6:12pm UTC](https://qa.fmod.com/t/js-scripting-api-checking-if-event-has-a-multi-instrument/23506 "2025-10-23T18:12:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CaioMJ](https://avatars.discourse-cdn.com/v4/letter/c/58f4c7/32.png) [@CaioMJ](https://qa.fmod.com/u/CaioMJ)\
**Post date:** [October 23, 2025, 6:12pm UTC](https://qa.fmod.com/t/js-scripting-api-checking-if-event-has-a-multi-instrument/23506/1 "2025-10-23T18:12:19Z")

</div>

Hello,

I’m writing a script with JS and writing a function that returns true if an event has a multi instrument on any parameter sheet. This is my current code:

```javascript
function HasVariations( event )
{
	var eventSheets = event.parameters;
	eventSheets.push( event.timeline );
	console.log("EVENT SHEETS: " + eventSheets );
		
	for( var i = 0; i < eventSheets.length; i++ )
	{
		var instruments = eventSheets[i].modules;
		console.log("INSTRUMENTS IN SHEET: " + instruments );
		
		for( var j = 0; j < instruments.length; j++ )
		{
			if (instruments[j].entity === "MultiSound" )
			{
				return true;
			}
		}
	}
	
	return false;
}

```

If my eventSheets variable only includes a timeline, this works fine. But if I’m iterating over an action sheet or other parameter sheet then I get the following error:

`TypeError: Result of expression 'instruments[j]' [undefined] is not an object., callstack:HasVariations(event = (ManagedObject:Event))`

How could I make this code work when iterating over both timelines and param sheets?

Thanks in advance!

EDIT: actually the error only seems to happen when iterating over an Action Sheet - timelines and other parameter sheets work fine

---

<div class="post-metadata">

**Author:** ![CaioMJ](https://avatars.discourse-cdn.com/v4/letter/c/58f4c7/32.png) [@CaioMJ](https://qa.fmod.com/u/CaioMJ)\
**Post date:** [October 23, 2025, 9:41pm UTC](https://qa.fmod.com/t/js-scripting-api-checking-if-event-has-a-multi-instrument/23506/2 "2025-10-23T21:41:01Z")

</div>

Same error happens when I try to `dump()` information from a module/instrument that lives in an action sheet vs a timeline/param sheet

---

<div class="post-metadata">

**Author:** ![CaioMJ](https://avatars.discourse-cdn.com/v4/letter/c/58f4c7/32.png) [@CaioMJ](https://qa.fmod.com/u/CaioMJ)\
**Post date:** [October 23, 2025, 10:17pm UTC](https://qa.fmod.com/t/js-scripting-api-checking-if-event-has-a-multi-instrument/23506/3 "2025-10-23T22:17:19Z")

</div>

Ok found a solution in this forum thread: [How can I get sheet content by javascript? - #4 by MisakaCirno](https://qa.fmod.com/t/how-can-i-get-sheet-content-by-javascript/21176/4)

TL;DR: Action sheets are actually multi instruments so instead of `eventSheets[i].modules `it had to be `eventSheets[i].modules.sounds` for action sheets.

Function ended up looking like this:

```auto
function HasVariations( event )
{
	var eventSheets = event.parameters;
	eventSheets.push( event.timeline );
	
	for( var i = 0; i < eventSheets.length; i++ )
	{
		var instruments = [];
		
		if( eventSheets[i].isOfExactType('ActionSheet'))
		{
			instruments = eventSheets[i].modules.sounds;
		}
		else
		{
			instruments = eventSheets[i].modules;
		}
		
		for( var j = 0; j < instruments.length; j++ )
		{
			if (instruments[j].entity == "MultiSound" )
			{
				return true;
			}
		}
	}	
	return false;
}

```

---

<div class="post-metadata">

**Author:** ![li\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/li_fmod/32/6577_2.png) [@li\_fmod](https://qa.fmod.com/u/li_fmod)\
**Post date:** [October 29, 2025, 4:30am UTC](https://qa.fmod.com/t/js-scripting-api-checking-if-event-has-a-multi-instrument/23506/4 "2025-10-29T04:30:06Z")

</div>

Thank you for sharing the solution here!
