# Small problem with toggleRecording() (Scripting API)

**URL:** https://qa.fmod.com/t/small-problem-with-togglerecording-scripting-api/15214
**Category:** FMOD Studio
**Created:** [November 13, 2019, 4:36pm UTC](https://qa.fmod.com/t/small-problem-with-togglerecording-scripting-api/15214 "2019-11-13T16:36:44Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![alexzzen](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/alexzzen/32/6825_2.png) [@alexzzen](https://qa.fmod.com/u/alexzzen)
#### Post date: [November 13, 2019, 4:36pm UTC](https://qa.fmod.com/t/small-problem-with-togglerecording-scripting-api/15214/1 "2019-11-13T16:36:44Z")

</div>

I’m doing some experiments with the Scripting API. I want to create a ProfilerSession, start recording on the session and go back to the selected Event in the Event Editor. It works if I input the code in the console, but when launching a .js script it seems like it can’t find the event object after calling `toggleRecording`. Using FMOD Studio 2.00.5.

This is a minimal code snippet to reproduce the issue:

```
    var event = studio.window.browserCurrent();
    var session = studio.project.create("ProfilerSession");

    studio.window.navigateTo(session);

    session.toggleRecording();

    studio.window.navigateTo(event);

```

Video of the behaviour when using the console:  
[https://streamable.com/jyiqv](https://streamable.com/jyiqv)

Running a script:  
[https://streamable.com/korld](https://streamable.com/korld)

What do I want to finally do with this code in the first place? I was planning to play with effects/modulations while the profiler is running, stop the recording and auto import the recorded .wav file from the profiler session into a new Event. It works great when copy+pasting the final code into the console, but doing that with a script that can be called with a shortcut would be even greater. It’s not very important (just experimenting), but thank you if you could look into it 🙂

---

<div class="post-metadata">

### Author: ![richard\_simms](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/richard_simms/32/261_2.png) [@richard\_simms](https://qa.fmod.com/u/richard_simms)
#### Post date: [November 25, 2019, 1:40am UTC](https://qa.fmod.com/t/small-problem-with-togglerecording-scripting-api/15214/2 "2019-11-25T01:40:54Z")

</div>

It looks like there’s a small bug when running these commands as a script. Basically navigating back to the event window is happening too quickly. I’ve logged a bug about this and we’ll look into it for a future release.
