How to dynamically change candidate groups for current process instance

I have defined a process with candidate groups that subscribe to a naming scheme such as GROUP_{{execution_variable}} and would like to substitute the {{execution_variable}} part for all tasks in the process instance when it is created/started.
Any suggestions about how I can go about this?
I was thinking of:
1 - A process execution listener, but I have seen nothing yet in the api that will allow me to get the user tasks and allow me to modify this, as user tasks are created at the execution points.
2 - A task execution listener, perhaps, that will fire on start of each task instance; which would mean that I’d have to add this [listener] for every user task in the process definition.

You can set the candidate groups to something like GROUP_${groupVar}, then setting groupVar to “foo” on the process would set the candidate groups to GROUP_foo. But it seems like you want to update the candidate groups on a task that has already been created. In that case, I think you’ll need to work with the task’s identity links.

This seems exactly like what I need, as the variable I need is present prior to process instantiation.
Will test and reply later.
Thanks. That worked.