Determine if an Execution exists

I have a groovy script that is failing when attempting to update a variable in another process. I can’t determine the correct way to check if the processInstanceId is still active. I am getting an error ‘ExecutionId is null’.

I think I have to use getExecutionId() but don’t know how to do that for another process.

Use getRuntimeService ()…pass in the process definition id to retrieve the process instance…then check whether it is active or not.

Thanks! I already know the processInstanceId, so I ran an execution query and checked if it returned an active execution, which seems to work for my purposes.