Is there a way to get the device id of the device that triggered the script?
I'm navigating surfaces on one iPad, and need the script to know, witch iPad is pressing the button.
not sure if I'm being clear...
Thank you
- Christian Scheuer @chrscheuer2021-04-24 16:27:56.055Z
You can access the device object through
event.surface.device
Currently, you cannot get the device id through that mechanism, but you can use the device object as input to the sf.surfaces.get('...').open() action's device parameter.
samuel henriques @samuel_henriques
Cool that worked.
Thank you so much.
samuel henriques @samuel_henriques
Hi Christian,
this has been working pretty good, with a commands like this:
sf.surfaces.get('user:ckdsx2kse0001rp10kif21fs8:ckkpz1im80000qx102tljvx6x').open({ device: event.surface.device, openMode: "OpenOrCreate", });
Now if/when I quit and re-open soundFlow, the devices go back to the soundFlow home, witch is fine. I even made script that will open the correct surface on all devices in one button.
But If I only restart soundFlow the surfaces stay up, scripts work, but these buttons to open surfaces won't run, I need to go back to home, refresh and select again.
I get this error: TypeError: Cannot read property 'device' of null
Which leads me to believe he forgot the name of the surface.Is there a way I could either get the devices to go home when I restart and I call the surface. Or just make this work.
Thank you so much.
samuel henriques @samuel_henriques
Another think I just found. If while the surface on the device is not working, If I open it on the computer, and press the same button, It works, opens the other surface on the device it was called from
samuel henriques @samuel_henriques
Hello @chrscheuer,
Sorry to bother you about this again, any idea of what I could do to fix this.
Maybe I'm not so clear.Thank you so much.
- In reply tosamuel_henriques⬆:
Christian Scheuer @chrscheuer2021-05-08 13:15:21.658Z
Hi Samuel
If you get
TypeError: Cannot read property 'device' of null
it's because you're running the above script with a trigger or something not being run directly from a surface.
Theevent.surface.device
will only work if the script is run by a button on an existing surface. So you can't reuse that same script and trigger it from somewhere else (for example an Application trigger), because in that caseevent.surface
would be null.You should instead make a macro using the action "Open Surface" and programmatically set the desired device, and assign a trigger to that.
You can learn how to do that here:
samuel henriques @samuel_henriques
Hey Christian,
Thank you for your time. I'm not sure this is the case, the script works as intended if I quit and open soundFlow or if I refresh the devices on the app home.
Only when I restart soundFlow, do I get error.here's a video:
https://we.tl/t-gDm22dnFPK
( I keep missing the place I click because I was looking at the phone :) )samuel henriques @samuel_henriques
The reason I'm using
event.surface.device
is also, so the surface on my left is always A and on my right is B, doesn't matter witch device it is. It will work.- In reply tosamuel_henriques⬆:
Christian Scheuer @chrscheuer2021-05-08 14:07:47.644Z
If this happens when you restart SF, then that sounds like the script has a trigger assigned that makes it run where event.surface is null (as I suggested).
Do you have triggers assigned to this command? You shouldn't.
samuel henriques @samuel_henriques
No, no triggers:
they all look like this.