After lot of tries, I gave up and use custom code, which took me 15 mins. That's how I did it:
function custom_dataset_views_pre_view ( &$view, &$display_id, &$args) {
if ($display_id === 'entityreference_1') {
// Get the node
$url = arg();
if ($url[1]) {
$node = node_load($url[1]);
$agency_id = $node->field_theme_working_group['und'][0]['target_id'];
// Get the views filter
$filters = $view->display_handler->get_option('filters');
if ($filters['field_agency_target_id']) {
// Change the filter
$filters['field_agency_target_id']['value']['value'] = $agency_id;
// Push the filter back
$view->display_handler->override_option('filters', $filters);
}
}
}
}
Despite it'sLess elegant, but finally working. Despite that, I would still would like to know how to achieve this in plain views, or using tokens.