How do I get access to the "execution" object in JavaScript?

In this section: https://docs.camunda.org/manual/7.8/user-guide/process-engine/scripting/#variables-available-during-script-execution: But not overly clear about the implications and how to visualize when you are in a specific scope.

Note that you can still access to the execution when inside of connector.

var parentScope = connector.getParentVariableScope()

context.setActivityId(parentScope.getCurrentActivityId());
context.setExecutionId(parentScope.getProcessInstanceId());
context.setProcessDefinitionId(parentScope.getProcessDefinitionId());

BUT see the following thread for more details and how its not a formal public interface, thus there are not guarantees: Error creating incident via javascript