Hey you can do this with the following
TB.render('your_component', function(data) {
const joinField = jQuery('#field_block_your_field select.select2', data.ele).select2();
const values = valueToSet.includes('[') ? JSON.parse(valueToSet.replace(/'/g, '"')) : [valueToSet];
values.forEach(value => {
jQuery(joinField).trigger({
type: 'select2:select',
params: { data: { id: value } }
});
});
jQuery(joinField).val(values).trigger('change.select2');
jQuery('#field_block_your_field .select2-container', data.ele).css('width','100%');
});
replace the component Id with the id of the component containing the connection field and replace the your_field text with the field id of the connection field.