Updating a slate-wide variable through an interaction on a slate widget

I am trying to update a local variable (in the variables tab) through an interaction in a custom code sandbox. I am able to access and read the variable in the code sandbox by adding it into the state section in the interactions tab.

However, how do i set this variable? I am currently using SlateFunctions.setState("<var_name>", <var_value>) in my javascript code within sandbox, but i think that just updates the state in the context of the sandbox widget, not the actual variable in the larger slate. Would i use an event or action to do this? and if so, how can i pass in parameters from the state to these events/actions?

I was able to do this using events - I created a custom event for a button that sets the slate-wide variable. I call this event when the button in my custom code sandbox is clicked. Works like a charm :slight_smile:

See the screenshot of an example below.